1

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.

1
  • Make sure you got the product is please check getid()
    – Keyul Shah
    Commented Oct 13, 2014 at 1:46

2 Answers 2

1

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

1

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();

0

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.