Prestashop module development: How can we save data from product page? - prestashop

I'm here for help from those who have real experience in Prestashop module development.
I got stucked while saving data from the product page where I've created the field through the module via hookDisplayAdminProductsExtra.
And I didn't get an idea to save new field data from the admin product page.
So, please help if anyone has a solution for this.
Thank You.

Add a form in your hook returned TPL,
so that you can retrieve and save your custom data in DB by registering and triggering "actionProductUpdate" in the module (this hook is called when a product is saved) by using Tools::getValue() inside the hook on your POST data.
Other solution would be to save data in AJAX with a dedicated AdminController - You can insert a custom button in your TPL + an additional JS file (you can include it with hookBackofficeHeader) to trigger the AJAX call.
You can see more about AdminController in official devdocs.

Related

How can I pass same data to multiple views in Odoo?

I have some data that I need to pass to every website views in Odoo. The problem is that I don't know the proper way to do that. I have thought about manually add them to every render method, but it doesn't feel right for me. And it violated DRY, of course.
I am using Odoo 12. Thank for your help!!
every page of odoo call website.layout template (for header & footer) so you can place your data in layout template and it will available in every page

Is it good to duplicate the opencart module?

Well I want to make a custom page in opencart admin panel to insert and delete some data from opencart database
For example :
Set an image slider on opencart home page and fetching images from database & for insertion of images, I want to create a custom page in opencart admin panel ??
So how can it be possible ??
You can duplicate any module and create other for your needs. Remember to duplicate and change the filename so the "new" extension can work properly.
Folder to consider for admin:
admin->controller->{type of module}->module's name
admin->model->(type of module)->module's name
admin->language->english (always)->(type of module)->module's name
optional:
admin->language->(other languages)->(type of module)->module's name
you may try,
1,Login as Admin-> systems -> design ->banners -> insert ->
YOUR BANNER NAME-> add banner ->
Title: YOUR TITLE
Image: YOUR IMAGE -> Save
2, Login as Admin-> extensions -> Modules ->Slideshow -> Edit -> add Module -> SELECT YOUR BANNER -> Save
Also when duplicating modules be aware that you may also need to change the existing class name to different one. For example when duplicating module flat rate you will also need to change in the controller /admin/controller/shipping/flat.php :
class ControllerShippingFlat extends Controller {
to something new like :
class ControllerShippingFlatDuplicate extends Controller {
It's posible, but in my opinion if you want to create a new "admin page" in your Opencart you can do it using vqmod.
so, you don't have to rewrite any core file.
you can donwload any free extension on the opencart website to take an example
You can simply duplicate some simple modules available in opencart admin panel like Welcome module or Banner or Slideshow module.
This method will help you to disable the module or change the position of content in future.
Duplicating opencart module tutorial : http://opencart.hostjars.com/blog/58
As a beginner it's better to duplicate an existing module and modifying it as per requirement. When you get the idea of how opencart modules work, you can build modules from scratch.
Yes, it is pretty safe and sound to duplicate a module in opencart and it is a bit logical with any of the cms as no one is going to create a module from scratch for a very little functionality like inserting some values to database.
As depicts you just want to insert some images links, so you can proceed with replicating the catalog / information functionality in opencart admin panel.
You just need to create a new table in database to store new modules data and fetching new module data in front end.
If you want to create a custom module or custom page for your store you can check below link. There is complete solutions for your question and describe very deeply.
Create custom module: http://www.php-dev-zone.com/2015/02/opencart-custom-module-development.html

Jive 7: How to change profile data / action?

I am writing a plugin for Jive (SBS) 7 and want to add more data to the template for the user profile Overview page (i.e. /people/admin ). In Jive 6 I did overwrite the profile path in struts and added my own ViewProfile action. But this action seems to be called no more.
I also cannot even figure out where the templates I changed get their data from (soy/people/profile/{userProfile, header, head}.soy) or what action is responsible for.
So how can I add another property to the soy file that gets a custom property for the targetUser? (custom property = property saved in the database table jiveuserprop)
You need to create a plugin and then use the option. Then, you simply use jquery to add the extra stuff.
you can create an action that takes in information using getters or post and throw it into the user's extended properties. You can create another action that'll retrieve that info in json.
then, simply use jquery's getJson to grab the info and use selectors to show the data in the user profile.
Don't forget to use the $j(document).ready(function(){ // your code here }); to show the info
simple example:
<scipt>
$j(document).ready(function(){
$j("div#j-profile-header-details").append("<p>hello World</p>");
});
</script>
will append "hello world" under the user's email address / job title.
hope this helps. feel free to ask more questions if it doesn't make sense. here's a good link on writing the javascript part of the plugin: http://docs.jivesoftware.com/jive/7.0/community_admin/index.jsp?topic=/com.jivesoftware.help.sbs.online/developer/PluginXMLReference.html
I got an answer in the Jive Developer community:
profile is an action in Struts2. /people/username is a URL Mapper permutation
https://community.jivesoftware.com/thread/263660

Is it possible to hook a module below the list of Customers in backoffice

I am working on a module, that has to add some HTML code under the list of customers in backoffice.
Are there any hooks on the 'Customers' page in backofice?
I could only find displayAdminCustomers Hook in the documentation, but this is actually a hook for a separate Customer page.
So, what would be the best way to include some HTML code under the list of Customers?
There are few solutions:
hook to the "footer" and check for the customers list page
add a new hook overriding the template & controller
use jQuery to add the necessary code
override the controller the display your custom template or fetch the current one and add your code
All the solutions have pros and cons based on what code you need to insert there.
Do you try the hook: displayAdminCustomersListAfter ?

Display a form in prestashop

I would like to show a form in prestashop module and would like to store that value in database. How is it possible?? Is there any prestashop expert ??
You may use custom HTML block and add your form code inside that. And off course have to use a hook to show up that HTML block in the site.
There are lots of free Custom HTML block modules available.
You should take a look at all the modules available in the modules/ directory.
If you want to display a form in the back and/or the front office, you'll have to override different methods of the Module class, and you'll have to use the different hooks available..
Best regards,
Try this free module :
https://www.prestashop.com/forums/topic/391966-megablock-16-module-gratuit/
With this one you can add HTML in some hooks from back-office.
Everything is stored in database.
You should use Helpers and Tools class (Helpers show forms and Tools::getValues() does what it says...)
In MegaBlock there is also TinyMCE available. Have a look, this module is really useful ;-)
you can develop a module by using hooks based on the hooks used the form will be displayed in that position in prestashop while using hooks you need to assign a tpl file in that tpl file you can write the codings to display a form
And also you can develop a module with a separate controller and you can assign a tpl for that controller.