0

i tried this code but it empty.

$collection = Mage::getModel('catalog/product')->getCollection();
            foreach($collection as $product){
                print_r($product->getmsrp());
            }exit;
2
  • Try $product->getMsrp();
    – Ravi Soni
    Jul 1 '19 at 6:12
  • It not working.
    – NewBie
    Jul 1 '19 at 6:17
0

Please Try this way.

I have tested it's working fine.

$collection = Mage::getModel('catalog/product')->getCollection();
$collection->addAttributeToSelect('*');
foreach($collection as $product) {
    $productData = $product->getData();
    $msrpPrice = $productData['msrp'];
    echo $msrpPrice;
}
2
  • Thank you. i got it.
    – NewBie
    Jul 1 '19 at 6:36
  • Thank for mark as a right answer. :)
    – Ravi Soni
    Jul 1 '19 at 6:37
0

Try this code and see if it is working

$collection = Mage::getModel('catalog/product')->getCollection();
$collection->addAttributeToSelect('*');
foreach($collection as $product){
    echo $product->getMsrp();
}

if you custom attribute code is msrp then getMsrp() should work.

If you still not getting your result then you need to set "use in product listing" option from manage attributes

Catalog -> Attributes -> Manage Attributes

Edit your attribute. In Storefront Properties tab select Used in Product Listing to "Yes"

then check again after reindex

4
  • i tried this code but it still not working
    – NewBie
    Jul 1 '19 at 6:23
  • did you add this code? $collection->addAttributeToSelect('*'); Jul 1 '19 at 6:28
  • what is the attribute code? Jul 1 '19 at 6:29
  • i got it. thank all <3
    – NewBie
    Jul 1 '19 at 6:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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