1

I want to make a simple module who show product details without header footer and other block. At first i try to get product info by id. But that say

Fatal error: Call to a member function getBackend() on boolean in D:\x\htdocs\m1\app\code\core\Mage\Eav\Model\Entity\Abstract.php on line 816

My code

class Abdus_Ajaxproduct_LoadproductController extends Mage_Core_Controller_Front_Action{
public function getbyidAction(){
    $_prdID=$this->getRequest()->getParam('id');
    $_product = Mage::getModel('catalog/product')->getCollection()->addFieldToFilter('id',$_prdID);
}}
2
  • 1
    try Mage::getModel('catalog/product')->load($_prdID); does that work?
    – pzirkind
    Commented Oct 25, 2015 at 22:07
  • Yes It work, and more I realize if I use sku then my code work properly. only problem when call ID. Commented Oct 26, 2015 at 3:49

2 Answers 2

2

Use:

 Mage::getModel('catalog/product')->load($_prdID);

Instead of:

Mage::getModel('catalog/product')->getCollection()->addFieldToFilter('id',$_prdID);
2

For the later comers:

Mage::getModel('catalog/product')->getCollection()->addFieldToFilter('entity_id',$_prdID);

From the point of view of an EAV model, there is no such field called "id".

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.