1

I am using the following URL in wishlist/item/list.phtml to move products from my wishlist to the cart.

 <?=$this->getBaseUrl()?>checkout/cart/add?product=<?=$item->getId()?>&qty=1

I understand that in order to move configurable items that the product options need to be included in the URL. I can't for the life of me figure out how to pull the super attributes IDs or how to include them in the URL.

1 Answer 1

1

To add a product to the cart with the super attributes set you will need the following url structure:

checkout/cart/add?product=product_id&super_attribute[attribute_id]=attribute_value

But I am a bit confused as to why you need this as by default the wishlist will save to custom options in the database and then the add to cart button on the wishlist will add the product with the options set.

The options saved against a product in the wishlist can be found on the table wishlist_item_option. Here you will see an entry for the code info_buyRequest and one for the code attributes, these are used when adding to a cart to set the attribute to the saved value.

You can also look at the wishlist controller to see how the core code adds configurable products. See in Mage_Wishlist_IndexController->cartAction where it loads the the buy request of the item and sets it to the cart item

$buyRequest = Mage::helper('catalog/product')->addParamsToBuyRequest(
    $this->getRequest()->getParams(),
    array('current_config' => $item->getBuyRequest())
);

$item->mergeBuyRequest($buyRequest);
$item->addToCart($cart, true);
1
  • 1
    Don't forget the form_key for the 1.8 version.
    – Marius
    Apr 25, 2014 at 11:47

Your Answer

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

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