0

I'm looking to extend the special price functionality in Magento and add some custom logic for when special prices should apply to products.

What is the most efficient way of doing this? Currently, there are observers for whenever the product is loaded (or whenever collections are loaded) and then the module checks if special price applies.

Obviously this way is very slow, what is a more effective way of doing this, possibly when the product itself is being pulled from the DB.

Any thoughts?

2
  • 1
    What you are describing - a module using a product load event to apply pricing logic is essentially the same as what you say you would like to acheive - applying logic when the product is 'pulled from the DB'. Why do you consider this method to be slow?
    – paj
    Aug 18, 2015 at 13:40
  • observers usually take a lot of overhead in terms of resources, when speed and scalability is in play rewriting / adding classes are at times faster
    – pzirkind
    Aug 18, 2015 at 14:54

1 Answer 1

2

In the observer, do you save the special price on the product?

For example:

$product->setSpecialPrice(123);

If so, then I would probably make a cronjob and run it each night. So every night you just run through all your products, if the price rules applies and are not already set, you just update the products special price and save it.

And if you want to run the script another time, just make a shell script and activate it that way at will.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.