Skip to content

Instantly share code, notes, and snippets.

@jonatanrdsantos
Created October 1, 2015 20:25
Show Gist options
  • Save jonatanrdsantos/69d1c59a0caa5950d915 to your computer and use it in GitHub Desktop.
Save jonatanrdsantos/69d1c59a0caa5950d915 to your computer and use it in GitHub Desktop.
Magento add products to cart via products IDS
<?php
public function addToAction()
{
$cart = Mage::getSingleton('checkout/cart');
$cart->addProductsByIds(
array(
$this->getRequest()->getParam('currentproduct'),
$this->getRequest()->getParam('relatedproduct')
)
);
$cart->save();
Mage::getSingleton('checkout/session')->setCartWasUpdated(true);
$this->_redirect('checkout/cart');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment