1

Display Bestsellers for Specific Magento Categories in CMS page.

Following tutorial,

https://mercytapscott.com/display-bestsellers-for-specific-magento-categories/

Added following line into cms content

{{block type="catalog/product_bestseller" template="catalog/product/bestseller.phtml" category_id="5"}}

Getting error.

My code :

app/code/local/Mage/Catalog/Block/Product/Bestseller.php app/design/frontend/default/theme/template/catalog/product/bestseller.phtml

If any configuration error or anything else?

error message : 

Fatal error: Call to a member function productAttribute() on null in /home/abc/public_html/app/design/frontend/default/theme/template/catalog/product/bestseller.phtml on line 6

7
  • please add code of block class and phtml
    – Pawan
    Dec 7, 2019 at 6:27
  • @vishal's answer is correct
    – Pawan
    Dec 7, 2019 at 6:43
  • @Pawan may i know why we need to declare $_helper = Mage::helper('catalog/output');?
    – zus
    Dec 7, 2019 at 6:45
  • 1
    because in your code you used <?php echo $_helper->productAttribute($_product, $_product->getName(), 'name') ?> but no where define $_helper!
    – Pawan
    Dec 7, 2019 at 6:47
  • 1
    you first need to create object by $_helper = Mage::helper('catalog/output'); before using it
    – Pawan
    Dec 7, 2019 at 6:48

1 Answer 1

2

open below file and declare of helper after flush and check it.

app/design/frontend/default/theme/template/catalog/product/bestseller.phtml

$_helper = Mage::helper('catalog/output');
11
  • Where i can declare $_helper = Mage::helper('catalog/output'); in my code : paste.ofcode.org/UWGbrJwSLyWkehW7yQu5rn
    – zus
    Dec 7, 2019 at 6:34
  • first line like <?php $_helper = Mage::helper('catalog/output'); ?> Dec 7, 2019 at 6:35
  • can you check category_id 5 exits and assign product that category? Dec 7, 2019 at 6:37
  • Yes, available..
    – zus
    Dec 7, 2019 at 6:40
  • 1
    because you can call of productAttribute function before you need to declare where it is function. Dec 7, 2019 at 6:47

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.