Jump to content

Copy a module


Recommended Posts

Hello, i need to have in my shop's home 2 "featured products" module, estetically the same but with different product.

I have try to copy the fratured products folder but obviously it dowsn't work, there's something to modify, but i don't know what... someone could help me?


Thanks

Link to comment
Share on other sites

At least, you need to change do following things
1. Change the folder, for example homefeatured1
2. Change related file name to a different ones. for example
homefeatured.php ->homefeatured1.php and homefeatured.tpl ->homefeatured1.tpl
3. Change the class name of copied module class to HomeFeatured1

             class HomeFeatured1 extends Module


4. change the modules name to different, 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));

  • Like 3
Link to comment
Share on other sites

It should work if you have done everything correctly. I have done this for some modules.

Please try to set 'display_errors' to 'on' in /config/config.inc.php file. See if there is any error displayed on the top of your page. It will give some hints where/what goes wrong.

Link to comment
Share on other sites

Ok, now it works, i have 2 modules.

But now when i modify the number of displayed product of one module it modify also the setting of the other module... i don't undestand why.


EDITED:
I have changed some variable name and now it works, but now i have a problem that i have no idea how to solve it.

This is my situation:
BLOCK Featured 1: 6 products showed
BLOCK Featured 2: 3 products showed

The 3 products of the second module is the the same as the fisrt three of the module 1.



Theres a way to put into the second module 3 different product?
In attachments there's the modified module.



Thanks

homefeatured2.zip

Link to comment
Share on other sites

It seems that I missed some instructions in my previous post. I have updated them.
These steps should work for most modules. But got HomeFeatured module, you need to do something more.


This is my situation:
BLOCK Featured 1: 6 products showed
BLOCK Featured 2: 3 products showed

The 3 products of the second module is the the same as the fisrt three of the module 1.
Theres a way to put into the second module 3 different product?

Why the problem occurs is that HomeFeatured 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));

Link to comment
Share on other sites

Now i deed to edit height of the module and top bar, i want a different one for the new module.

There a way to not copy all that code but change only these 2 rows?
background: transparent url('../img/block_header_large.png') no-repeat top left;
height: 370px;

Link to comment
Share on other sites

  • 8 months later...

At least, you need to change do following things

1. Change the folder, for example homefeatured1

2. Change related file name to a different ones. for example

homefeatured.php ->homefeatured1.php and homefeatured.tpl ->homefeatured1.tpl

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

		  class HomeFeatured1 extends Module

4. change the modules name to different, 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));

 

 

Great tip!

 

You're also missing this, you need to change this one too:

 

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

  • Like 2
Link to comment
Share on other sites

  • 1 year later...
  • 1 year later...
  • 3 months later...

hello

 

you mean that you want to display products from several categories?

 

NO . i mean home featured, home 2 featured, home 3 featured

 

home featured   > assign category called > Today Promotions

home 2 featured > Assign category called > Own Development Products

home 3 featured > Assign category called > Electo products

 

i want to selected or show Only some categories which i want to show in index page

Link to comment
Share on other sites

  • 10 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...