0
votes

I have added a product in **sales_flat_quote table in advance for a particular customer**.. then later i have to call that item. when i take that product and then add to cart by using /checkout/cart/add/?product=[id]&qty=[quantity]. The product will get doubled in cart.. how can i view cart without using /checkout/cart/add/?product=[id]&qty=[quantity]. Is there any model for getting that url.

Thanks in advance.

2
This question is incomprehensible.Alan Storm

2 Answers

4
votes

If I understand your question then I believe Mage::getUrl('checkout/cart') is what you want. That will give just the /checkout/cart url which is what you need to view the shopping cart without performing any actions on it.

0
votes

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