Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

exception 'BadMethodCallException' with message 'Call to a member function addData() #33

Open
engrKaka opened this issue Nov 28, 2016 · 0 comments

Comments

@engrKaka
Copy link

engrKaka commented Nov 28, 2016

Hello all,
I facing this issue when I try to load product collection in chunks
exception 'BadMethodCallException' with message 'Call to a member function addData() on a non-object (null)' in /app/code/community/Smile/MongoCatalog/Model/Resource/Override/Catalog/Product/Collection.php:173
in _loadAttributes() function. My code is
`public function updateIndex()
{
$productsCollection = Mage::getModel('catalog/product')->getCollection()
->addFieldToFilter('visibility', Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH);

$productsCollection->setPageSize(100);

$pages = $productsCollection->getLastPageNumber();
$currentPage = 1;

do {
    $productsCollection->setCurPage($currentPage);
    $productsCollection->load();

    foreach ($productsCollection as $_product) {

        $insertData = array(
            'entity_id' => $_product->getId(),
            'title' => $_product->getName(),
            'image' => $_product->getImage(),
            'url' => $_product->getUrlKey(),
            'price' => $_product->getFinalPrice(),
        );

        $this->_getWriteAdapter()->insertOnDuplicate(
            $this->getTable('atwix_sonar/suggestions'),
            $insertData,
            array('title', 'image', 'url', 'price')
        );
    }

    $currentPage++;
    //clear collection and free memory
    $productsCollection->clear();
} while ($currentPage <= $pages);

}`
Note this is just test code from atwix tutorial
Do you have any solution for this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant