Jump to content

[SOLVED]use promotions articles into homepage


Recommended Posts

Hi guys,

Is there anybody who managed to show all your promotions (that you can see in promotions/aanbiedingen) to be shown on the first page?

On my site I show features products, but I want to show also my promotion articles, this is why people come to my site :-)

any idea how I can add an extra module like feature products but with my promotions or how I can change the feature product query into the promotion query?

thanks in advance for any tip or link.

Deech

Link to comment
Share on other sites

Rocky I will,

but can you just give me one tip?
in his query I want to show the random records.
this is his line :

       $products = Product::getPricesDrop(intval($cookie->id_lang), 0, $nb); 
       $products = Product::getPricesDrop(intval($cookie->id_lang), intval($p) - 0, (intval($nb ? $nb : 4)), false, $orderBy, $orderWay);



any idea, everything I change result in hack attempt

Link to comment
Share on other sites

Hi rocky

If I change the code in to this :

       $products = Product::getPricesDrop(intval($cookie->id_lang), 0, $nb); 
       $products = Product::getPricesDrop(intval($cookie->id_lang), intval($p) - 0, (intval($nb ? $nb : 4)), false, $orderBy, $orderWay);
   $products = shuffle($products);



then I get a empty box with price 0, no picture?
what could be wrong?

Link to comment
Share on other sites

rocky this is better but still not good enough :-)

when I have 8 products in promotion and show only 4 then the shuffle does it work but does not take the other 4 products in mixed order, only the First 4 and there it shuffled , but still the same 4... the rest not.

hope I'm telling this clear enough :-)

thx in advance

Link to comment
Share on other sites

The only solution then it to hack PrestaShop's code, which I don't like to do. You will need to change line 1201 of classes/Product.php from:

static public function getPricesDrop($id_lang, $pageNumber = 0, $nbProducts = 10, $count = false, $orderBy = NULL, $orderWay = NULL, $beginning = false, $ending = false, $withDiscount = 0)



to:

static public function getPricesDrop($id_lang, $pageNumber = 0, $nbProducts = 10, $count = false, $orderBy = NULL, $orderWay = NULL, $beginning = false, $ending = false, $withDiscount = 0, $random = false)



and change line 1258 from:

ORDER BY '.(isset($orderByPrefix) ? pSQL($orderByPrefix).'.' : '').'`'.pSQL($orderBy).'`'.' '.pSQL($orderWay).'



to:

ORDER BY '.($random ? 'RAND()' : ((isset($orderByPrefix) ? pSQL($orderByPrefix).'.' : '').'`'.pSQL($orderBy).'`'.' '.pSQL($orderWay))).'



then change the module's code from:

$products = Product::getPricesDrop(intval($cookie->id_lang), intval($p) - 0, (intval($nb ? $nb : 4)), false, $orderBy, $orderWay);



to:

$products = Product::getPricesDrop(intval($cookie->id_lang), intval($p) - 0, (intval($nb ? $nb : 4)), false, $orderBy, $orderWay, false, false, 0, true);

  • Like 3
Link to comment
Share on other sites

works like a charm.

I also did a change for the prices without reduction in percentage and there was an error when clients see the prices without tva then the old price was still price with tva, so I changed it :-)

thanks for you rocking help :-)

Link to comment
Share on other sites

  • 1 year 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...