Jump to content

How to change category from 'home' to something else in homefeatured module in 1.5?


Recommended Posts

// Posted this in the general section, but then realized it was better suited here! Oops D:

 

HELLO!

 

I want to change the homefeatured module so that it doesn't show products from just "home" category, but "Accessories" category.

 

I've looked around the forums and found out so far that we have to change this line in homefeatured.php, 1 bring the ID of the category:

 

$products = $category->getProducts((int)Context::getContext()->language->id, 1, ($nb ? $nb : 10));

 

to

 

$products = $category->getProducts((int)Context::getContext()->language->id, 37, ($nb ? $nb : 10));

 

It's not working for me though. When I change it to 37, it states "no featured products", when I already have 2 products in Accessories. Am I missing something in 1.5?

 

Thank you in advance!!

  • Like 1
Link to comment
Share on other sites

  • 1 month later...

Try this: change

$category = new Category(Context::getContext()->shop->getCategory(), (int)Context::getContext()->language->id);

to

$category = new Category(37, (int)Context::getContext()->language->id);

 

Do not change this line:

$products = $category->getProducts((int)Context::getContext()->language->id, 1, ($nb ? $nb : 10));

Edited by silberstern (see edit history)
  • Like 5
Link to comment
Share on other sites

  • 2 months later...
  • 5 months later...

Hi, thanks for you solution, it works very good.

 

But I have a problem: my shop is in italian and in english language, as I choose the italian language everything works good, as I select the english language there is no product in the homefeatured module, it is written "No featured products".

 

Can somebody help me?

 

Thanks.

Regards

Miriam

Link to comment
Share on other sites

Hi Vekia,

thanks a lot for your prompt replay.

 

But if I reinstall the module, the file that I have edited will be overwritten from the original one.

Infact I tried your suggestion and it work, but then as I edit the file again in order to see in the homefeatured module the products of another category I have the same problem.

 

Any other ideas?

 

 

 

Thank u again.

Regards

Miriam

Link to comment
Share on other sites

Hi,

yes I am sure that my issue is due to the modification I used.

 

I have done the following modification in the file homefeatured.php:

 

from

 

$category = new Category(Context::getContext()->shop->getCategory(), (int)Context::getContext()->language->id);

 

I change to

 

$category = new Category(37, (int)Context::getContext()->language->id);

 

 

 

Where 37 is the id of my categorie, it works, but not if I change language.

  • Like 1
Link to comment
Share on other sites

Dear Vekia, I solved the problem, thanks.

 

For other person who need to know how to change the homefeatured module so that it doesn't show products from just "home" category but from another category and they have a website multilanguage I explain the correct procedure:

 

in the file homefeatured.php in modules/homefeatured chage the line

 

$category = new Category(Context::getContext()->shop->getCategory(), (int)Context::getContext()->language->id);

$nb = (int)(Configuration::get('HOME_FEATURED_NBR'));

$products = $category->getProducts((int)Context::getContext()->language->id, 1, ($nb ? $nb : 10));

 

in

 

 

$category = new Category(6, (int)Context::getContext()->shop->getCategory(), (int)Context::getContext()->id_lang);

$nb = (int)(Configuration::get('HOME_FEATURED_NBR'));

$products = $category->getProducts((int)Context::getContext()->language->id, 1, ($nb ? $nb : 10));

 

 

where 6 is the id number of the category you choose.

 

Hope this can be helpful for somebody else and thank you for your support.

 

Regards

Miriam

Link to comment
Share on other sites

  • 4 weeks later...

Hi there - This didn't seem to work for me - no big deal but I maybe have a 'variation on theme' ;)

 

I created a category "Featured Products" and when associating a product i tick 3 boxes. home, the real category & the featured products.

 

My home screen shows the standard plugin home screen as usual but now I can offer a menu item in the category listing that is just showing the featured, so in other words a listing of what the home screen shows in it's own page.

 

Hope that helps another head scratcher out there.

Link to comment
Share on other sites

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

Hi, I try in this but it doesn't work

 $category = new Category(Context::getContext()->shop->getCategory(), (int) Context::getContext()->language->id);
            $nb = (int) Configuration::get($this->name . '_qty_products');
            $products = Product::getNewProducts((int) Context::getContext()->language->id, 0, ($nb ? $nb : 5));
Link to comment
Share on other sites

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...