Menggandakan modul pada prestashop

The PrestaShop modular features are the one of the best features I think. Most functionality can be developed separately and independently. And further more, it is open for any contributors who would like to contribute to the community.

Sometime, store owners want to duplicate some the modules like Advertiser block module, home featured module so the they can use more than one in the application.
Here I explain in detailed instruction on how to duplicate a module with examples.

Steps to duplicate a module: (use Home Featured module as an example)
1. Copy the existing module and rename to it for new name, for example
From: homefeatured to:homefeatured1

2. Change related file name to a different ones. for example
From: homefeatured.php To: homefeatured1.php
Ffom: homefeatured.tpl To:homefeatured1.tpl

3. Change the class name of copied module class to HomeFeatured1

class HomeFeatured1 extends Module

4. Change the modules name in the class constructor to a different one, for example

$this->name = 'homefeatured1';

5. If don not want to share the parameters, you have to change the parameter name for example, HOME_FEATURED_NBR1

Configuration::updateValue('HOME_FEATURED_NBR1', intval($nbr));

6. Change new module to use new UI(tpl) file homefeatured1.tpl file

return $this->display(__FILE__, 'homefeatured1.tpl');

7. (for Prestashop 1.4 or higher), change the module name,and tab name in configre file config.xml.



 blockadvertising1
    Block advertising123
    0.1
    Adds a block to display an advertisement123
    advertising_marketing
    1
    0



8. If the module load data from database, you need to change the part that load data.
This code usually in HookXXXXX() function. For example, HookHome, HookLeft, HookRight.
For Home Featured module are getting data from product category “Home”.
If you want load completely different data, you need use another category and for the 2nd module, load data from different category. Change the following “1” to your new category id, for example, 111.

code before change
$products = $category->getProducts(intval($params['cookie']->id_lang), 1, ($nb ? $nb : 10));

code after change
$products = $category->getProducts(intval($params['cookie']->id_lang), 1111, ($nb ? $nb : 10));

http://alvinjiang.blogspot.com/2011/01/prestashop-tips-how-to-duplicate.html

Comments

Popular posts from this blog

Windows XP SP3 Product Key

SEF pada Virtuemart

Tentang google page rank