1

I am trying to add a "Buy now" button to the category page of my store. I have followed the following guide;

http://www.ifuelinteractive.com/jquery-magento-and-ajax-add-to-cart-redux/

Making a few changes to the layout of the form. I can see that my values are getting into the PHP script, and if I ouput debug points in the PHP, it gets as far as;

$cart->addProduct($product, $qty);

And this causes the exception "The product could not be found" to appear in the console. I can check the logs and see that this exception is coming from core/mage/checkout/model/cart.php which does indeed contain the exception, and is throwing it when...

    $currentWebsiteId = Mage::app()->getStore()->getWebsiteId();
    if (!$product
        || !$product->getId()
        || !is_array($product->getWebsiteIds())
        || !in_array($currentWebsiteId, $product->getWebsiteIds())
    ) {
        Mage::throwException(Mage::helper('checkout')->__('The product could not be found.'));
    }
    return $product;

I then output getWebsiteIds() of $product in the addToCart.php file that is being loaded in via Ajax and the array is empty. Leading me to believe that the exception is being thrown because the php file is unable to pick up the website IDs associated with the product.

I should mention that I am using Organic Internet Simple Configurable Products - and configurable products are used on the list.phtml category, however simple product IDs are loaded into the Ajax script via a dropdown menu, and these are getting loaded into the addToCart.php file correctly (I can see via debuging). On Magento V 1.12

Thanks in advance

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.