3

I am stuck in a situation where I can't edit/create any new customers using the backend in magento.

The requirement was simple: Create some customer attributes, so I installed this extension to do the job.

It seems to add the attributes that I created using the customer attributes section from the backend but after that I can't access the customers section from the backend. Everytime I try it gives me this error Fatal error: Call to a member function addCustomerIdFilter() on a non-object in xxxxx\app\code\core\Mage\Adminhtml\Block\Customer\Edit\Tab\View\Accordion.php on line 74

I tried everything including un-installing the extension but it doesn't help. Please can anyone guide me how to solve this?

2 Answers 2

4

Okay, I solved it.

The problem arises if you have disabled the Wishlist functionality in your store. It seems like Magento didn't implemented a check to find whether Wishlist is enabled or not in the file Mage_Adminhtml_Block_Customer_Edit_Tab_View_Accordion. So enabling the wishlist fixed the problem.

Although its a drag to keep the wishlist module active even though I don't need it.

1
  • 1
    Happy that it works! But magento team should have done a check whether Wishlist is active or not. If it helps you... I wrapped the section inside an IF tag to check if wishlist is enabled.
    – Tarun
    Jan 16, 2015 at 14:22
1

Complementing the above answer, just add an override on a new or current module: In the config.xml

    <global>
            <blocks>
                <adminhtml>
                    <rewrite>
<customer_edit_tab_view_accordion>Yournamespace_Customer_Block_Adminhtml_Customer_Edit_Tab_View_Accordion</customer_edit_tab_view_accordion>
                    </rewrite>
                </adminhtml>
            </blocks>
        </global>

And add a new class overriding the block with a little validation:

class Yournamespace_Customer_Block_Adminhtml_Customer_Edit_Tab_View_Accordion extends Mage_Adminhtml_Block_Customer_Edit_Tab_View_Accordion
{
    protected function _prepareLayout()
    {
        $customer = Mage::registry('current_customer');

        $this->setId('customerViewAccordion');

        $this->addItem('lastOrders', array(
            'title'       => Mage::helper('customer')->__('Recent Orders'),
            'ajax'        => true,
            'content_url' => $this->getUrl('*/*/lastOrders', array('_current' => true)),
        ));

        // add shopping cart block of each website
        foreach (Mage::registry('current_customer')->getSharedWebsiteIds() as $websiteId) {
            $website = Mage::app()->getWebsite($websiteId);

            // count cart items
            $cartItemsCount = Mage::getModel('sales/quote')
                ->setWebsite($website)->loadByCustomer($customer)
                ->getItemsCollection(false)
                ->addFieldToFilter('parent_item_id', array('null' => true))
                ->getSize();
            // prepare title for cart
            $title = Mage::helper('customer')->__('Shopping Cart - %d item(s)', $cartItemsCount);
            if (count($customer->getSharedWebsiteIds()) > 1) {
                $title = Mage::helper('customer')->__('Shopping Cart of %1$s - %2$d item(s)', $website->getName(), $cartItemsCount);
            }

            // add cart ajax accordion
            $this->addItem('shopingCart' . $websiteId, array(
                'title'   => $title,
                'ajax'    => true,
                'content_url' => $this->getUrl('*/*/viewCart', array('_current' => true, 'website_id' => $websiteId)),
            ));
        }

        // count wishlist items
        //THIS IS THE ADDED VALIDATION
        if (Mage::helper('core')->isModuleEnabled('wishlist')) {
            $wishlistCount = Mage::getModel('wishlist/item')->getCollection()
                ->addCustomerIdFilter($customer->getId())
                ->addStoreData()
                ->getSize();
            // add wishlist ajax accordion
            $this->addItem('wishlist', array(
                'title' => Mage::helper('customer')->__('Wishlist - %d item(s)', $wishlistCount),
                'ajax'  => true,
                'content_url' => $this->getUrl('*/*/viewWishlist', array('_current' => true)),
            ));
        }

    }

} 

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.