This product with current option is not available Magento

193 Views Asked by At

I keep getting Error

  • This product with current option is not available

in the cart page of Magento, I can add to cart, but when i open the cart page, it give this error, it happens in configurable products, I traced it to

/public_html/app/code/core/Mage/CatalogInventory/Model/Stock/Item.php

from line 545 to line 551

   /**
     * Check if child product assigned to parent
     */
    $parentItem = $this->getParentItem();
    if ($this->getIsChildItem() && !empty($parentItem)) {
        $typeInstance = $parentItem->getProduct()->getTypeInstance(true);
        $requiredChildrenIds = $typeInstance->getChildrenIds($parentItem->getProductId(), true);
        $childrenIds = array();
        foreach ($requiredChildrenIds as $groupedChildrenIds) {
            $childrenIds = array_merge($childrenIds, $groupedChildrenIds);
        }
        if (!in_array($this->getProductId(), $childrenIds)) {
            $result->setHasError(true)
                ->setMessage(Mage::helper('cataloginventory')
                    ->__('This product with current option is not available'))
                ->setQuoteMessage(Mage::helper('cataloginventory')->__('Some of the products are not available'))
                ->setQuoteMessageIndex('stock');                   
            return $result;
        }
    }

from what I can get that in this if statement

if (!in_array($this->getProductId(), $childrenIds))

This $this->getProductId() comes back with wrong product ID, which is VERY WEIRED

I'm Using Magento 1.9.3, and Porto Theme, I tried on different servers, with a clean version of Magento with no plugins or theme, still getting the same error. I can't get my head around it, can use a fresh set of eyes, I don't have any custom options.

0

There are 0 best solutions below