0

I am working on manipulating the magento product prices, so that the price is retrieved from an ERP system - instead of from the magento mysql.

So far, I have the succeeded with the prices in the product view, cart, orders etc.

Product view

However, the price displayed on the category view is giving trouble.

Category view

Can anyone kindly enlighten me on where the price "Special Price: 1,00 kr" is generated for this view? The price "1,00" is taken from the Magento DB currently, so I need to override that price in this view - similar to the product view.

Thank you

2
  • If you think prices will be used from ERP, then you should also consider "catalog price rule" of Magento will not be applicable. In my opinion just use custom price.phtml where you might get regular price/special price from ERP feed, so there is no need to rely on Magento price or that long 'price.phtml' logic! One thing is sure - you will find "filter by price" not usable if you do get live feeds from ERP. Feb 24, 2014 at 8:23
  • It will not work, technically you can do it but unless you use some pretty special tools it is not a viable option in realtime, we know, we have used a solution and it slows down the system too much (they implemented solutions to fix this). You will also have Google indexing and visitor checkout issues, dynamic page loads needs to be 1-2s, you will never achieve that with external system calls.
    – user2935
    Mar 25, 2014 at 18:05

2 Answers 2

2

The price shown in the list of products comes from the price index tables and not the product tables itself.
The join with this tables are made (sort of) in Mage_Catalog_Model_Resource_Product_Collection::addPriceData().
Digging deeper you should end up in this method Mage_Catalog_Model_Resource_Product_Collection::_productLimitationPrice()

I also have a suggestion if I may. You shouldn't pull prices directly from an ERP at 'runtime'. This can make the the website very slow. I suggest having a cron that runs every X hours and fills updates the product prices and special prices if needed and rebuilds the price indes when the import is done. This way you can let Magento have its usual flow. The prices section is highly delicate and can lead to very big problems.

5
  • Hi Marius, thank you for your reply. I agree with you about pulling prices from ERP at runtime. However, due to a very complex price matrix in the ERP (which is by no means compatibel with Magento), I am forced to do a runtime query. I have however created a shadow mysql database to do price query from, so hopefully that helps with the overhead...:-) Your solution is a step in the right direction, however I still need to figure out the exact price override. Sep 27, 2013 at 8:04
  • @ChristianHansen You're welcome, but did it solve your problem?
    – Marius
    Sep 27, 2013 at 8:06
  • Please see my edit above :-) Sep 27, 2013 at 8:08
  • Basically, I need to find the correct place in your suggestion to put my mysql query, before any tax calculations takes place. I.e. create a baseprice & a specialprice. Sep 27, 2013 at 8:24
  • 1
    That is a really bad idea, we work with a pricing system with multiple tiers of calculation and use standard Magento pulled from external tools. Price is so embedded in the platform you will never stabilise it (indexing, special prices, grouped/bundle/configurable products, tax calculations). It is a technical approach to try and solve a business problem, not a good idea.
    – user2935
    Sep 27, 2013 at 14:47
0

Create an observer for the event catalog_product_get_final_price. Here is an example to customize the price based on current customer:

public function catalogProductGetFinalPrice($observer)
{
    if(Mage::getSingleton('customer/session')->isLoggedIn()) {
        $product = $observer->getEvent()->getProduct();
        $customer = Mage::getSingleton('customer/session')->getCustomer();
        $this->adjustPriceForCustomer($product, $customer);
    } else {
        $this->adjustPrice($product);
    }
}

Please let me know if you need help to define an observer.

1

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.