2

I have a little big problem. After the migration of the catalog for a new store in a "clean" installation of Magento I started to have problems with configurable products. When you select an option and click buy, instead of adding the product to cart, returns the error message:

Fatal error: Call to a member function setProductName () on a non-object in /home/alter648/public_html/compras/app/code/core/Mage/CatalogInventory/Model/Observer.php on line 387

Searching on the internet I found something similar in https://stackoverflow.com/questions/26414137/cannot-add-to-cart-configurable-product-after-migration-magento but that did not solve.

Already checked the records of the configurable product and simple products, and found no difference in relation to the registration in the previous store. I checked and saved and changed nothing.

Does anyone have any idea how to solve?

4 Answers 4

3

This depends on how you migrated the catalog.
The error appears if there is not stock record for the product you are trying to add to cart.
You can try a reindex, but I doubt that will solve it.
But I bet the problem will be solved if you edit the product in the backend and save it.
Of course, this is not a solution if you have a lot of products in your store, but it's at least a starting point.

2
  • 1
    Tks Maius. But in this case the stock isn't managed. Mar 22, 2016 at 16:51
  • 1
    It does not matter. Even if the stock is not managed, a record for the stock should be present in the db.
    – Marius
    Mar 22, 2016 at 17:11
0

Just for the record as solved: I solved the problem by simply opening the simple and saving products. I think that's what was presented as a solution on the link below, but I understood it was to access the configurable product, and not simply as I did.

0

You imported programmatically your products, but did you initialize stock ?

Even if stock are not managed in Magento, each products must have an entry in stock model 'cataloginventory/stock_item'.

To create stock model assigned to product, you can use something like :

if (!$stockItemId) {
    Mage::getModel('cataloginventory/stock_item')
        ->assignProduct($product)
        ->setData('stock_id', 1)
        ->setData('store_id', 0) // You can use Mage::app()->getStore()->getStoreId() if needed
        ->setData('manage_stock', 0) // Magento wont manage stock
        ->setData('qty', 1) // But Qty is 1
        ->setIsInStock(Mage_CatalogInventory_Model_Stock::STOCK_IN_STOCK) // And product is in stock
        ->setProcessIndexEvents(false) // Speed up you update script (usefull for synch scripts)
        ->save();
        $resultmaj .= 'stock initialisé, ';
}

Finally, reindex everuthing just in case :-)

0

This can cause because of following reason ->All the attributes that you had in previous store has not been added in attribute sets. Re-indexing might solve the problem afterwards. Solution: Create all attributes that were present in previous store and update it via magmi for configurable product if there are any. And Another solution is as @marius suggested edit and save manually. Shortcut would be selecting all product and add "<NULL>" in description with editing attributes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.