Magento - Fatal error: calling getBackend () member function for non-object in app / code / core / Mage / Eav / Model / Entity / Abstract.php on line 816

Getting this error when trying to use a custom filter inside a custom theme.

I set the new attribute is_featured and its attribute set. I made a product that designated it as recognized (yes / no)

My homepage (in the CMS section) includes the following "panel"

<block type="catalog/product" name="catalog.product_featured_list" template="catalog/product/featured_list.phtml" after="-"/> 

featured_list.phtml is as follows:

 <?php $storeId = Mage::app()->getStore()->getId(); $_productCollection=Mage::getResourceModel('reports/product_collection') ->addAttributeToSelect(array('name', 'url', 'small_image', 'price', 'short_description')) ->addAttributeToFilter('is_featured', 1) ->addAttributeToFilter('status', 1) ->setPageSize(3) ->setStoreId($storeId) ->addStoreFilter($storeId); $_helper = $this->helper('catalog/output'); ?> <?php if($_productCollection->count()): ?> <section class="content-box clearfix"> <header> <h2>Featured products</h2> </header> <ul class="featured-products"> <?php foreach ($_productCollection as $_product): ?> <?php $_productNameStripped = $this->stripTags($_product->getName(), null, true); ?> <li> <h3> <a href="<?php echo $_product->getProductUrl(); ?>" title="<?php echo $_productNameStripped; ?>"> <?php echo $_helper->productAttribute($_product, $_product->getName() , 'name'); ?> </a> </h3> <a href="<?php echo $_product->getProductUrl(); ?>" title="<?php echo $_productNameStripped; ?>"> <img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(212); ?>" width="200" height="200" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" /> </a> <div> <ul class="clearfix"> <li>From &pound;<?php echo number_format($_product->price, 2) ?></li> <li> <?php $desct = nl2br($this->htmlEscape($_product->getShortDescription())); $desct = strip_tags($_product->getShortDescription()); ?> <p> <? echo Mage::helper('core/string')->truncate($desct, '100'); ?> <a href="<?php echo $_product->getProductUrl(); ?>" title="<?php echo $_productNameStripped; ?>"> <?php echo $this->__('more details'); ?> </a> </p> </li> <li> <form action="<?php echo $this->helper('checkout/cart')->getAddUrl($_product); //echo $this->getAddToCartUrl($_product); ?>" class="product-list-add-to-cart" method="get" id="product_addtocart_form_<?php echo $_product->getId()?>"<?php if($_product->getOptions()): ?> enctype="multipart/form-data"<?php endif; ?>> <?php if(!$_product->isGrouped()): ?> <label for="qty"><?php echo $this->__('Qty') ?>:</label> <input type="text" class="input-text qty" name="qty" id="qty" maxlength="12" value="<?php echo ($this->getMinimalQty($_product)?$this->getMinimalQty($_product):1) ?>" /> <input type="hidden" name="product" value="<?php echo $_product->getId()?>" /> <?php endif; ?> <button type="button" class="button" onclick="this.form.submit()"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button> </form> </li> </ul> </div> </li> <?php endforeach; ?> </ul> </section> <?php endif; ?> 

It seems the problem is with the collection at the beginning of the block. (I can remove this panel from the home page and the site will load fine)

I am sure that all available attributes are available (is_featured looks like a single user attribute)

(This topic was inherited, so I’m not 100% versed in how it works! I just copy it)

+8
source share
2 answers

I am currently using 1.7, and whenever I get the message "Calling the getBackend () member function on an error other than the object ...", this is usually due to calling the wrong model or applying a filter to an attribute that does not exist in this collection.

After testing the code, it works without problems (basically ...) if I comment on this line:

 ->addAttributeToFilter('is_featured', 1) 

My suggestion is to double check that the product attribute identifier exists in your current installation and that it is installed in the correct area (Global / Correct Store?).

If it exists correctly, another solution is to select manually selected products, you can try:

 Mage::getModel('catalog/product')->getCollection() ->addAttributeToSelect(array('name', 'url', 'small_image', 'price', 'short_description')) ->addFieldToFilter('is_featured', 1) ->addFieldToFilter('status', 1) ->addStoreFilter($storeId) ->clear()->setPageSize(3)->load(); //setPageSize = How Many Products To Show 

And see if that fixes.

+10
source

In my case, it helped comment out on this line (line 765)

 $customer->changeResetPasswordLinkCustomerId($newResetPasswordLinkCustomerId); 

in

/app/code/core/Mage/Customer/controllers/AccountController.php

0
source

All Articles