Jump to content

Featured products sort order


Recommended Posts

In this case (this module hasn't got advanced configuration) you can only edit php files of module. Which type of order you want to implement?

Ok, I just thought missed it somehow (although I spent a lot of time looking for the function), because I assumed that such a simple function was there :)

 

I want them in a "customised" order of my own choosing (based on which products I want to sell more of and thus give it more attention on the page).

 

I will try to edit the php code, but I also found out that the products appear in the order in which they were added to the featured (home) category, so a solution is also to remove the products so the featured is empty and then add the products in the order you want them (the last one is added first).

Link to comment
Share on other sites

  • 1 month later...

Hello guys. I found this topic after searching for a solution to the same problem. In order to to achieve what colorrush (and I) is asking here:

 

I will try to edit the php code, but I also found out that the products appear in the order in which they were added to the featured (home) category, so a solution is also to remove the products so the featured is empty and then add the products in the order you want them (the last one is added first).

 

...I edited the file /PRESTASHOPDIR/modules/homefeatured/homefeatured.php and changed line 106 (PS 1.5.3.1):

 

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

 

to this:

 

// webmaster changes start
//		$products = $category->getProducts((int)Context::getContext()->language->id, 1, ($nb ? $nb : 10));
	$products = array_reverse($category->getProducts((int)Context::getContext()->language->id, 1, ($nb ? $nb : 10)));
// webmaster changes end

 

 

Now, the display order of the products in the Homefeatured block is the reverse, meaning that the product you add last in the Home category will be displayed first, and so on.

 

Hope this helps!

 

 

DISCLAIMER: I am not a particularly experienced PHP developer. The hack above may seem trivial/simple, but I shall take no responsibility in the unlikely case where it causes your PrestaShop site to crash and burn!

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

  • 3 months later...

Yes Parsifal your code rearranges the order of the display. However what I am looking for is to show the latest added products in the featured area. So we have over 100 products and we we want the latest added products to be seen in the featured area.

Link to comment
Share on other sites

  • 2 months later...

Hello guys. I found this topic after searching for a solution to the same problem. In order to to achieve what colorrush (and I) is asking here:

 

 

 

...I edited the file /PRESTASHOPDIR/modules/homefeatured/homefeatured.php and changed line 106 (PS 1.5.3.1):

 

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

 

to this:

 

// webmaster changes start
//		$products = $category->getProducts((int)Context::getContext()->language->id, 1, ($nb ? $nb : 10));
	$products = array_reverse($category->getProducts((int)Context::getContext()->language->id, 1, ($nb ? $nb : 10)));
// webmaster changes end

 

 

Now, the display order of the products in the Homefeatured block is the reverse, meaning that the product you add last in the Home category will be displayed first, and so on.

 

Hope this helps!

 

 

DISCLAIMER: I am not a particularly experienced PHP developer. The hack above may seem trivial/simple, but I shall take no responsibility in the unlikely case where it causes your PrestaShop site to crash and burn!

 

Thank you.. I tried this, great.. :D

Link to comment
Share on other sites

Assuming the number of featured products you have doesn't run into the hundreds, the simplest way to achieve this is to edit the position column for category 2 in the ps_category_product table and put the products in the order you want.

 

I'm not normally an advocate of direct updates to the database, but I believe you're pretty safe with this one.

Link to comment
Share on other sites

  • 1 month later...

Hello guys. I found this topic after searching for a solution to the same problem. In order to to achieve what colorrush (and I) is asking here:

 

 

 

...I edited the file /PRESTASHOPDIR/modules/homefeatured/homefeatured.php and changed line 106 (PS 1.5.3.1):

 

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

 

// webmaster changes start
//		$products = $category->getProducts((int)Context::getContext()->language->id, 1, ($nb ? $nb : 10));
		$products = array_reverse($category->getProducts((int)Context::getContext()->language->id, 1, ($nb ? $nb : 10)));
// webmaster changes end

Now, the display order of the products in the Homefeatured block is the reverse, meaning that the product you add last in the Home category will be displayed first, and so on.

 

Hope this helps!

 

 

DISCLAIMER: I am not a particularly experienced PHP developer. The hack above may seem trivial/simple, but I shall take no responsibility in the unlikely case where it causes your PrestaShop site to crash and burn!

 

 

This helped me! it's not perfect, but it works!

Link to comment
Share on other sites

  • 11 months later...

Hi everyone,

 

I am having the same issue, but for "new Product" section, i am using prestashop 1.4.2, and using velvet sky free theme. i have two category, first one is home safes and second is office safes, (please visit www.mastersafe.net), at home page i have slider who slide feature product and new arrival product. i want feature product shown from Home safes category and new product from Office Product Category.

Is this Possible???? 

 

 

Any one please help.....i am not hard core programmer,so it is very difficult....

Link to comment
Share on other sites

  • 1 year later...

Hello guys. I found this topic after searching for a solution to the same problem. In order to to achieve what colorrush (and I) is asking here:

 

 

 

...I edited the file /PRESTASHOPDIR/modules/homefeatured/homefeatured.php and changed line 106 (PS 1.5.3.1):

 

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

 

// webmaster changes start
//		$products = $category->getProducts((int)Context::getContext()->language->id, 1, ($nb ? $nb : 10));
		$products = array_reverse($category->getProducts((int)Context::getContext()->language->id, 1, ($nb ? $nb : 10)));
// webmaster changes end

Now, the display order of the products in the Homefeatured block is the reverse, meaning that the product you add last in the Home category will be displayed first, and so on.

 

Hope this helps!

 

 

DISCLAIMER: I am not a particularly experienced PHP developer. The hack above may seem trivial/simple, but I shall take no responsibility in the unlikely case where it causes your PrestaShop site to crash and burn!

 

 

 

Hello! I tried this but its not working for me! Any other solution??

here is my code:

if (Configuration::get('HOME_FEATURED_RANDOMIZE'))
				/*HomeFeatured::$cache_products = $category->getProducts((int)Context::getContext()->language->id, 1, ($nb ? $nb : 8), null, null, false, true, true, ($nb ? $nb : 8));*/

HomeFeatured::$cache_products = array_reverse($category->getProducts((int)Context::getContext()->language->id, 1, ($nb ? $nb : 8), null, null, false, true, true, ($nb ? $nb : 8)));
			else
				/*HomeFeatured::$cache_products = $category->getProducts((int)Context::getContext()->language->id, 1, ($nb ? $nb : 8), 'position');*/

HomeFeatured::$cache_products = array_reverse($category->getProducts((int)Context::getContext()->language->id, 1, ($nb ? $nb : 8), 'position'));
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...