Adding a Product to the Cart via Querystring
For Simple Product :
$this->getUrl('checkout/cart').'add?product='.$pro_id.'&qty='.$qty.';
where : $pro_id= 'Product id' ; $qty = 'Product Quentity'
For Simple Product with Custome Option:
$this->getUrl('checkout/cart').'add?product = '.$pro_id.'&qty = '.$qty.'&options['.$pro_value.'] = '.$pro_opt_val.'
where : $pro_value= 'Product option_id';$pro_opt_val= 'Product option_type_id';
For Bundle Product :
$this->getUrl('checkout/cart').'add/product/['.$pro_id.']/?bundle_option[['.option_id.']][]=['.selection_id.']
like if bundle product's id is 2790 than :
$_product = Mage::getModel('catalog/product')->load(2790);
if ($_product->getTypeId() == 'bundle')
{
$w = Mage::getSingleton('core/resource')->getConnection('core_write');
$result = $w->query("select `option_id`, `selection_id` from `catalog_product_bundle_selection` where `parent_product_id`=$id");
$route = "checkout/cart/add";
$params = array('product' => $id);
while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
$params['bundle_option['. $row[option_id] .']'][] = $row['selection_id'];
};
header("Location: ". Mage::getUrl($route, $params));
}
For Adding a Configurable Product to the Cart via Querystring:
http://www.your_domain.com/checkout/cart/add?product = 68&qty = 1&super_attribute[528] = 55& super_attribute[525] = 56
$params = array(
'product' => 23,
'qty' => 2,
);
$cart = Mage::getSingleton('checkout/cart');
$product = new Mage_Catalog_Model_Product();
$product->load(23);
$cart->addProduct($product, $params);
$cart->save();
Mage::getSingleton('checkout/session')->setCartWasUpdated(true);
For Configurable Product :
For Simple Product :
$this->getUrl('checkout/cart').'add?product='.$pro_id.'&qty='.$qty.';
where : $pro_id= 'Product id' ; $qty = 'Product Quentity'
For Simple Product with Custome Option:
$this->getUrl('checkout/cart').'add?product = '.$pro_id.'&qty = '.$qty.'&options['.$pro_value.'] = '.$pro_opt_val.'
where : $pro_value= 'Product option_id';$pro_opt_val= 'Product option_type_id';
For Bundle Product :
$this->getUrl('checkout/cart').'add/product/['.$pro_id.']/?bundle_option[['.option_id.']][]=['.selection_id.']
like if bundle product's id is 2790 than :
$_product = Mage::getModel('catalog/product')->load(2790);
if ($_product->getTypeId() == 'bundle')
{
$w = Mage::getSingleton('core/resource')->getConnection('core_write');
$result = $w->query("select `option_id`, `selection_id` from `catalog_product_bundle_selection` where `parent_product_id`=$id");
$route = "checkout/cart/add";
$params = array('product' => $id);
while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
$params['bundle_option['. $row[option_id] .']'][] = $row['selection_id'];
};
header("Location: ". Mage::getUrl($route, $params));
}
For Adding a Configurable Product to the Cart via Querystring:
http://www.your_domain.com/checkout/cart/add?product = 68&qty = 1&super_attribute[528] = 55& super_attribute[525] = 56
Here 68 is the product entity id displayed in magento admin panel. 528 and 525 is the attribute associated with this product and 55 and 56 is the selected value of that attribute.
Another way to add product in cart :
For Simple Product :
'product' => 23,
'qty' => 2,
);
$cart = Mage::getSingleton('checkout/cart');
$product = new Mage_Catalog_Model_Product();
$product->load(23);
$cart->addProduct($product, $params);
$cart->save();
Mage::getSingleton('checkout/session')->setCartWasUpdated(true);
For Configurable Product :
$params = array(
'product' => 23,
'super_attribute' => array(
528 =>55,
),
'qty' => 2,
);
$cart = Mage::getSingleton('checkout/cart');
$product = new Mage_Catalog_Model_Product();
$product->load(23);
$cart->addProduct($product, $params);
$cart->save();
Mage::getSingleton('checkout/session')->setCartWasUpdated(true);
'product' => 23,
'super_attribute' => array(
528 =>55,
),
'qty' => 2,
);
$cart = Mage::getSingleton('checkout/cart');
$product = new Mage_Catalog_Model_Product();
$product->load(23);
$cart->addProduct($product, $params);
$cart->save();
Mage::getSingleton('checkout/session')->setCartWasUpdated(true);
http://www.domain.com/CatList.php
. You can find the csv file in thevar/import/
directory.