Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The problem with the current answer is that magento will not add a second line item if the SKU is the same but the options are distinct from the first. If you want a 3" apple and a 4" apple you would like to have separate line items. Or at least I do.</p> <p>A HTTP call to the following URL</p> <pre><code>/store/checkout/cart/add?product=23&amp;qty=1&amp;options[41]=4 </code></pre> <p>followed by </p> <pre><code>/store/checkout/cart/add?product=23&amp;qty=1&amp;options[41]=3 </code></pre> <p>will add two line items.</p> <p>But still this is just half of the battle, what do these option codes stand for?? Well the following PHP code will tell you. And since we are using an HTTP call the code will return javascript ready JSON.</p> <pre><code>&lt;?php include_once '../app/Mage.php'; Mage::app(); echo getProductOptionsIds($_GET['eventcode']); function getProductOptionsIds($sku) { $ProductID = Mage::getModel('catalog/product')-&gt;getIdBySku($sku); $Product = Mage::getModel('catalog/product')-&gt;load($ProductID); $config = array(); $config['ProductID'] = $ProductID; foreach ($Product-&gt;getOptions() as $option) { // @var $option Mage_Catalog_Model_Product_Option if ($option-&gt;getGroupByType() == Mage_Catalog_Model_Product_Option::OPTION_GROUP_SELECT) { $_tmpValues = array(); foreach ($option-&gt;getValues() as $value) { // @var $value Mage_Catalog_Model_Product_Option_Value $_tmpValues[$value-&gt;getTitle()] = $value-&gt;getId(); } $config[$option-&gt;getTitle().'list'] = $option-&gt;getId(); $optionValue = $_tmpValues; } else { $optionValue = $option-&gt;getId(); } $config[$option-&gt;getTitle()] = $optionValue; } return json_encode($config); } ?&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload