tag:blogger.com,1999:blog-8662105787759613580.post7584924907236523190..comments2023-05-30T06:13:14.028-07:00Comments on My tech memo: PrestaShop Tips - How to duplicate a existing module?Alvinhttp://www.blogger.com/profile/07842202617495536815noreply@blogger.comBlogger28125tag:blogger.com,1999:blog-8662105787759613580.post-3204190012004472522013-01-24T02:53:59.091-08:002013-01-24T02:53:59.091-08:00Very nice indeed...
THANK YOU!
WaldoVery nice indeed...<br />THANK YOU!<br /><br />WaldoAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-8662105787759613580.post-41610779136698660762012-11-09T15:08:39.556-08:002012-11-09T15:08:39.556-08:00Hi Alvin,
Finally manage to solve category issue....Hi Alvin,<br /><br />Finally manage to solve category issue. Solution is simple and needed a break to clear my mind from this issue. There is only one place that needs to be changed and this is first parameter, representing category id, in following line:<br /><br />$category = new Category(1, Configuration::get('PS_LANG_DEFAULT'));<br /><br />This line should not be changed:<br /><br />$products = $category->getProducts((int)($params['cookie']->id_lang), 1, ($nb ? $nb : 10));<br /><br />Another thing that I have noticed is that category should not be enabled.<br /><br />Hope this is helpful for other Prestashop fans.<br />Colinnoreply@blogger.comtag:blogger.com,1999:blog-8662105787759613580.post-7131434151910909822012-10-27T09:44:32.213-07:002012-10-27T09:44:32.213-07:00Hi Colin
Thanks for your comment.
Yes you are rig...Hi Colin<br />Thanks for your comment.<br /><br />Yes you are right, for the text to be able to translatable at back office, you need put mod='modulename'.<br /><br />For the category, any category should be OK as long as you put the products on that category.<br /><br />If you do have products in that category but it does not hit, then you need to debug the category->getProducts() function to see what it wrong.<br /><br />Please note:<br />make sure the category is visible to the current user (loged in user) or visitor. The access is controlled by Customer Group.<br /><br />Alvinhttps://www.blogger.com/profile/07842202617495536815noreply@blogger.comtag:blogger.com,1999:blog-8662105787759613580.post-65489471968096982132012-10-27T05:49:31.388-07:002012-10-27T05:49:31.388-07:00Hi Alvin,
I have manage to solve translation issu...Hi Alvin,<br /><br />I have manage to solve translation issue in my previous comment. I would like to share my solution. It requires to change "mod" value to new module name in .tpl file. Eg.<br /><b>mod='homefeatured'</b> becomes <b>mod='myhomefeatured'</b><br /><br />Still looking forward for a solution to get products in the module no matter what category id I use...colinnoreply@blogger.comtag:blogger.com,1999:blog-8662105787759613580.post-11562135283961618242012-10-26T15:09:15.663-07:002012-10-26T15:09:15.663-07:00Hi Alvin,
Very nice and useful post. Following th...Hi Alvin,<br /><br />Very nice and useful post. Following the guidelines I was able to duplicate home featured module.<br />Still few things that not working for me:<br />I am not able to get products in this new module for all categories that I have defined. For some of them it works, for some it don't. And, yes, I do have products in all of my categories.<br />I also have a problem with translations. Even if I have define them for the duplicated module, they are not showing.<br /><br />I got confused: you have reply to two of the comments, two things that for me seems to be opposite:<br /><br /><b>August 11, 2012 6:04 AM:</b><br />"make sure you have used the correct category ID and you have products in that category.<br /><b>Also there will be two places you need to replace the number "1" as showing below.</b><br />$category = new Category(1, Configuration::get('PS_LANG_DEFAULT'));<br />$nb = (int)(Configuration::get('HOME_FEATURED_NBR'));<br />$products = $category->getProducts((int)($params['cookie']->id_lang), 1, ($nb ? $nb : 10));"<br /><br /><b>October 22, 2012 3:19 PM</b><br />"You use wrong category ID.<br />$category = new Category(50, Configuration::get('PS_LANG_DEFAULT'));<br /><b>Home featured is only on Home category which ID is 1.<br />You need to change 50 to 1.</b>"<br /><br />Is this prestashop version dependent? I am using 1.4.8.2 version.colinnoreply@blogger.comtag:blogger.com,1999:blog-8662105787759613580.post-19311504763533413142012-10-22T21:15:38.625-07:002012-10-22T21:15:38.625-07:00Yes, I know, at first it was set to 1 for the cate...Yes, I know, at first it was set to 1 for the category field but still getting the same msg so I have changed it.<br /><br />Anyway today I have writed again 1 for category field, uploaded file, uninstall and install again but still getting the msg that there is no products.<br /><br />Below is the homefeatured1.php file in TXT, if you could have a look ?<br /><br />http://textuploader.com/?p=6&id=8y6gPYangnoreply@blogger.comtag:blogger.com,1999:blog-8662105787759613580.post-88303239869572080392012-10-22T15:19:01.980-07:002012-10-22T15:19:01.980-07:00You use wrong category ID.
$category = new Catego...You use wrong category ID.<br /><br />$category = new Category(50, Configuration::get('PS_LANG_DEFAULT'));<br /><br /><br />Home featured is only on Home category which ID is 1.<br />You need to change 50 to 1.<br /><br />Alvinhttps://www.blogger.com/profile/07842202617495536815noreply@blogger.comtag:blogger.com,1999:blog-8662105787759613580.post-2057996499490006172012-10-22T05:18:52.115-07:002012-10-22T05:18:52.115-07:00I tried to duplicate the module homefeatured but i...I tried to duplicate the module homefeatured but it show no products in the homepage. Instead I am getting the msg : No featured products. I have followed exactly as your tutorial, here is a part pf the file modified : <br /><br /> function hookHome($params)<br /> {<br /> global $smarty;<br /><br /> $category = new Category(50, Configuration::get('PS_LANG_DEFAULT'));<br /> $nb = (int)(Configuration::get('HOME_FEATURED_NBR1'));<br /> $products = $category->getProducts((int)($params['cookie']->id_lang), 50, ($nb ? $nb : 10));<br /> $smarty->assign(array(<br /> 'products' => $products,<br /> 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'),<br /> 'homeSize' => Image::getSize('home')));<br /><br /> return $this->display(__FILE__, 'homefeatured1.tpl');<br /> }<br />}Yangnoreply@blogger.comtag:blogger.com,1999:blog-8662105787759613580.post-48081767693386870242012-10-08T16:34:38.548-07:002012-10-08T16:34:38.548-07:00>I did not see anything mentioned about adding ...<br />>I did not see anything mentioned about adding the module to prestashop. <br />>Is it suppose to show up by itself once the duplication you described is done? <br /><br />Yes, it should show up automatically if there is no errors. I guess the copied module still have some errors. Make sure you have rename the module class name to the same name of folder.<br /><br />Try to turn on the error display to see if there is any error. Set "display_errors" to "on" in file /config/config.inc.php<br /><br /><br />Alvinhttps://www.blogger.com/profile/07842202617495536815noreply@blogger.comtag:blogger.com,1999:blog-8662105787759613580.post-55792728543599782102012-10-02T09:59:25.087-07:002012-10-02T09:59:25.087-07:00I duplicated the whole module folder and renamed f...I duplicated the whole module folder and renamed folder, files, and inside files as you outlined, but the new module name does not list under the Modules tab of the prestashop admin panel. version 1.4.9.<br /><br />I did not see anything mentioned about adding the module to prestashop. Is it suppose to show up by itself once the duplication you described is done? <br />So far it has not.<br /><br />Any other steps needed to make it show up in the modules list of pretashop?Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8662105787759613580.post-10109560578226710102012-08-11T06:04:56.085-07:002012-08-11T06:04:56.085-07:00make sure you have used the correct category ID an...make sure you have used the correct category ID and you have products in that category.<br /><br />Also there will be two places you need to replace the number "1" as showing below.<br /><br /><br />$category = new Category(1, Configuration::get('PS_LANG_DEFAULT'));<br /><br />$nb = (int)(Configuration::get('HOME_FEATURED_NBR'));<br /><br />$products = $category->getProducts((int)($params['cookie']->id_lang), 1, ($nb ? $nb : 10));Alvinhttps://www.blogger.com/profile/07842202617495536815noreply@blogger.comtag:blogger.com,1999:blog-8662105787759613580.post-84079081797359712332012-06-06T00:58:55.991-07:002012-06-06T00:58:55.991-07:00I have same problem as Florina in 1.4.5.1 when I s...I have same problem as Florina in 1.4.5.1 when I select another category number, he module says 'No featured products". What is the fix Alvin?Rekhahttps://www.blogger.com/profile/02166394800924884286noreply@blogger.comtag:blogger.com,1999:blog-8662105787759613580.post-9683453107188574032012-02-25T06:56:42.780-08:002012-02-25T06:56:42.780-08:00if you can share the URL, maybe I can have look at...if you can share the URL, maybe I can have look at when I got a chanceAlvinhttps://www.blogger.com/profile/07842202617495536815noreply@blogger.comtag:blogger.com,1999:blog-8662105787759613580.post-77540667016948642162012-02-22T22:30:23.930-08:002012-02-22T22:30:23.930-08:00Hi Allen, thanks again for your help. I tried you...Hi Allen, thanks again for your help. I tried your suggestion, and the link still doesn't work - it's really strange!<br />The weird thing is, on the module that works, I can click on the image, right click and save, etc. On the module that doesn't work, I'm not able to do this.<br /><br />I'm not sure you can help me on this, but it's making me tear my hair out!<br /><br />Thanks again.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8662105787759613580.post-44399612594303800812012-02-20T15:55:18.255-08:002012-02-20T15:55:18.255-08:00the only thing i can image is that something wrong...the only thing i can image is that something wrong with the theme file (tpl), such as tag mismatched. Some tag is not closed.<br /><br />Try to copy the tpl file from the one that it works, then make necessary again to see if it solve your problem.Alvinhttps://www.blogger.com/profile/07842202617495536815noreply@blogger.comtag:blogger.com,1999:blog-8662105787759613580.post-61683385967014061932012-02-19T13:46:39.473-08:002012-02-19T13:46:39.473-08:00Hi Alvin,
Thanks for the response. I already made...Hi Alvin,<br />Thanks for the response. I already made sure all instances of BLOCKADVERT_LINK were changed to BLOCKADVERT_LINK2. The link still doesn't work. It's strange. The first block advertising works perfectly. On the second one, the image is fine, the text is fine. But the link does not work. For some strange reason, if I insert a horizontal line in there, it will link (just the line though). But image link doesn't work. I hope you can help!Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8662105787759613580.post-47982375889938766332012-02-12T12:32:12.273-08:002012-02-12T12:32:12.273-08:00fantastic post, easy to understand, have got an is...fantastic post, easy to understand, have got an issue thought the title for image is the same in all blocks anyone knows how to edit this please?Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8662105787759613580.post-91144445475331497912012-02-10T14:17:49.175-08:002012-02-10T14:17:49.175-08:00Hi Alvin,
Thanks for response. I have changed all...Hi Alvin,<br />Thanks for response. I have changed all instances of BLOCKADVERT_LINK to BLOCKADVERT_LINK2, and the link is still not working.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8662105787759613580.post-82875144851473797712012-02-10T05:12:36.038-08:002012-02-10T05:12:36.038-08:00please make sure you have changed the configuratio...please make sure you have changed the configuration variable name and you saved and retrieved from the correctly one for each module.<br /><br /><br />Here is example: Configuration::updateValue('BLOCKADVERT_LINK', 'http://www.prestashop.com');Alvinhttps://www.blogger.com/profile/07842202617495536815noreply@blogger.comtag:blogger.com,1999:blog-8662105787759613580.post-51479350293800616922012-02-08T22:40:26.428-08:002012-02-08T22:40:26.428-08:00Hi, and thank you for this super helpful post. I ...Hi, and thank you for this super helpful post. I *almost* succeeded in duplicating the block advertising module. The image and text seem to be appearing ok. However, it doesn't seem to be able to link to a URL. The other advertising module is working fine. Do you know what I could be doing wrong? Thanks!!Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8662105787759613580.post-73986992580815837252011-12-06T08:25:38.983-08:002011-12-06T08:25:38.983-08:00Thanks a lot for your post. It worked fine for me,...Thanks a lot for your post. It worked fine for me, with prestashop 1.4.5. I would only add that It's also important to change $this->displayName if you want to be able to distinguish easily among de different versions of the modules.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8662105787759613580.post-43053039305611282552011-10-08T06:26:09.612-07:002011-10-08T06:26:09.612-07:00I think you there is a problem inside hookHome() w...I think you there is a problem inside hookHome() where you call a function to get your product list. Check that the function return correct product list as expected.Alvinhttps://www.blogger.com/profile/07842202617495536815noreply@blogger.comtag:blogger.com,1999:blog-8662105787759613580.post-70584746481825526262011-10-08T02:36:29.241-07:002011-10-08T02:36:29.241-07:00Hi there!
It works to duplicate the module.
Howev...Hi there! <br />It works to duplicate the module.<br />However, if I want to load data from another category it stops working. It shows the module and the following line: "No featured products"<br /><br />Is there anything else I should do?Florinahttp://www.doti.ronoreply@blogger.comtag:blogger.com,1999:blog-8662105787759613580.post-4512127423150145172011-06-12T19:23:19.991-07:002011-06-12T19:23:19.991-07:00this is really what i need. thanx bro.
Ahmad, Jaka...this is really what i need. thanx bro.<br />Ahmad, Jakarta, IndonesiaAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-8662105787759613580.post-28334551193568301322011-05-30T23:28:03.955-07:002011-05-30T23:28:03.955-07:00good one!t
thank yougood one!t<br />thank youLeszekhttps://www.blogger.com/profile/17589867783457649599noreply@blogger.com