Magento add package element directly to the basket from upsell - predefined parameters

I am trying to add a related item to the basket from the upsell area with the selected options - so it will lead you directly to the basket and not to the elements page, and I use the following URL:

Mage::$this->helper('checkout/cart')->getAddUrl($_link)

combined, for example:

?bundle_option[14][]=16&bundle_option[15][]=17&bundle_option[16][]=19&

This URL then adds the item to the trash, but with a warning:

Some of the products below do not have all the required parameters. Change them and configure all the necessary parameters.

And I won’t let me continue checking. It also contains a message about the successful addition to the basket.

If I add an item from its own page (with all the default options), it works fine.

I set it as Add product to cart without specifying parameters , with radio buttons selected and default.

Also, adding parameters options_bundle_qty[...to the url doesn't help.

Update . I have exactly the same setting for 1.4 and 1.6, it works in version 1.4, but not 1.6

+3
source share
1 answer

You can try creating a single test.php file with something like:

$params = array(
    'product' => 164,
    'related_product' => null,
    'bundle_option' => array(
        21 => 58,
        20 => 55,
        11 => 28,
        12 => array(
            0 => 31,
        ),
        13 => array(
            0 => 32,
            1 => 35,
        ),
    ),
    'options' => array(
        3 => 'olaaaaaaaa',
    ),
    'qty' => 2,
);

$cart = Mage::getSingleton('checkout/cart');

$product = new Mage_Catalog_Model_Product();
$product->load(164);

$cart->addProduct($product, $params);
$cart->save();

Mage::getSingleton('checkout/session')->setCartWasUpdated(true);

$message = $this->__('Custom message: %s was successfully added to your shopping cart.', $product->getName());
Mage::getSingleton('checkout/session')->addSuccess($message);

To test and debug the addition of product packages so that it is easier to identify any problems. Obviously, you will want to edit the product identifier and the parameters that will be associated with the data you need.

, .

+4

All Articles