Can someone please explain how to properly configure and where to get the ID's, names, options, etc of this code?
I've been searching but other questions only leads to the solution of some mistake, but I need first to know where to get the numbers that are requered.
It's supposed to get a custom product and add it to the cart.
$product_id = 12;
$id_opt_value = 12;
$final_opt_value = 12;
$product = Mage::getModel('catalog/product')->load($product_id);
$cart = Mage::getModel('checkout/cart');
$cart->init();
$params = array(
'product' => $product_id,
'qty' => 1,
'options' => array(
$id_opt_value => '123456',
$final_opt_value => 'black gloss finish',
)
);
This is the complete code:
require_once '../app/Mage.php';
umask(0);
/* not Mage::run(); */
Mage::app('default');
Mage::getSingleton("core/session", array("name" => "frontend"));
$product_id = 12;
$id_opt_value = 12;
$final_opt_value = 12;
$product = Mage::getModel('catalog/product')->load($product_id);
$cart = Mage::getModel('checkout/cart');
$cart->init();
$params = array(
'product' => $product_id,
'qty' => 1,
'options' => array(
$id_opt_value => '123456',
$final_opt_value => 'black gloss finish',
)
);
$cart->addProduct($product, $params);
$cart->save();
Any help is appreciated.