Question

I've created an extension of the Mage_Catalog_Model_Product_Type_Price module where I will dynamically load prices from an external database.

I need the product sku in order to retrieve the correct price from my DB. I used Mage::getModel('catalog/product')->load($_product->getId())->getSku();

but that doesn't appear to be working.

Was it helpful?

Solution 2

I found the answer by looking at how Magento core modules calls product specific attributes like $product->getData('price'); and found that $product->getData('sku'); worked perfectly!

FYI - I had to change my module and the above methods stopped working. I had to switch to $this->getSku();

OTHER TIPS

First check for PHP errors in your web server log.

If on Apache: http://www.codeasite.com/index.php/linux-a-apache/94-how-do-i-find-apache-http-server-log-files

This might give you an indication of where the problem is at. Your $_product variable might not be defined or, it could be a conflict within an extension.

Also check the Magento system and exception logs - if it is not enabled, enable it then you should be able to see the logs under <magento base dir>/var/log

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top