Hope It helps!
in observer.php
<?php
class SmashingMagazine_LogProductUpdate_Model_Observer
{
public function logUpdate(Varien_Event_Observer $observer)
{
if (Mage::app()->getRequest()->getParam('item_id')) {
//remove Cart
Mage::getSingleton('checkout/cart')->truncate();
// Mage::getSingleton('checkout/cart')->save();
$item_id = Mage::app()->getRequest()->getParam('item_id');
$qty = Mage::app()->getRequest()->getParam('qty');
$product = Mage::getModel('catalog/product')->load($item_id);
$cart = Mage::getModel('checkout/cart');
$cart->init();
$cart->addProduct($product, array('qty' => $qty));
$cart->save();
Mage::getSingleton('checkout/session')->setCartWasUpdated(true);
}
}
}
config.xml
<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<SmashingMagazine_LogProductUpdate>
<version>0.0.1</version>
</SmashingMagazine_LogProductUpdate>
</modules>
<global>
<models>
<smashingmagazine_logproductupdate>
<class>SmashingMagazine_LogProductUpdate_Model</class>
</smashingmagazine_logproductupdate>
</models>
<events>
<controller_action_layout_load_before>
<observers>
<smashingmagazine_logproductupdate>
<class>smashingmagazine_logproductupdate/observer</class>
<method>logUpdate</method>
<type>singleton</type>
</smashingmagazine_logproductupdate>
</observers>
</controller_action_layout_load_before>
</events>
</global>
</config>
You can call your cart URL:
http://yourURL.com/checkout/cart?item_id=2&qty=300
It will add 300 items of product id 2
Code is here: https://github.com/alan345/magento-URL-to-cart