Skip to main content
added 6 characters in body
Source Link
Adarsh Khatri
  • 8.4k
  • 3
  • 28
  • 59
<?xml version="1.0" encoding="UTF-8"?>

<config>
    <modules>
        <DigitalCinema_Pos><NameSpace_ModuleName>
            <version>1.0.8</version>
        </DigitalCinema_Pos>NameSpace_ModuleName>
    </modules>

    <global>
        <models>
            <namespace>
                <class>NameSpace_ModuleName_Model</class>
            </namespace>
        </models>
        <events>
            <checkout_cart_product_add_after>
                <observers>
                    <update_qty_on_product_add_to_cart>
                        <type>singleton</type>
                        <class>NameSpace_ModuleName_Model_Observer</class>
                        <method>updateQty</method>
                    </update_qty_on_product_add_to_cart>
                </observers>
            </checkout_cart_product_add_after>
        </events>
    ............
    </global>
</config>
<?xml version="1.0" encoding="UTF-8"?>

<config>
    <modules>
        <DigitalCinema_Pos>
            <version>1.0.8</version>
        </DigitalCinema_Pos>
    </modules>

    <global>
        <models>
            <namespace>
                <class>NameSpace_ModuleName_Model</class>
            </namespace>
        </models>
        <events>
            <checkout_cart_product_add_after>
                <observers>
                    <update_qty_on_product_add_to_cart>
                        <type>singleton</type>
                        <class>NameSpace_ModuleName_Model_Observer</class>
                        <method>updateQty</method>
                    </update_qty_on_product_add_to_cart>
                </observers>
            </checkout_cart_product_add_after>
        </events>
    ............
    </global>
</config>
<?xml version="1.0" encoding="UTF-8"?>

<config>
    <modules>
        <NameSpace_ModuleName>
            <version>1.0.8</version>
        </NameSpace_ModuleName>
    </modules>

    <global>
        <models>
            <namespace>
                <class>NameSpace_ModuleName_Model</class>
            </namespace>
        </models>
        <events>
            <checkout_cart_product_add_after>
                <observers>
                    <update_qty_on_product_add_to_cart>
                        <type>singleton</type>
                        <class>NameSpace_ModuleName_Model_Observer</class>
                        <method>updateQty</method>
                    </update_qty_on_product_add_to_cart>
                </observers>
            </checkout_cart_product_add_after>
        </events>
    ............
    </global>
</config>
Source Link
Adarsh Khatri
  • 8.4k
  • 3
  • 28
  • 59

I would suggest you to achieve this from observer.

This event checkout_cart_product_add_after should help you.

You will need to create a simple extension to fire this event.

In your config.xml have this:

<?xml version="1.0" encoding="UTF-8"?>

<config>
    <modules>
        <DigitalCinema_Pos>
            <version>1.0.8</version>
        </DigitalCinema_Pos>
    </modules>

    <global>
        <models>
            <namespace>
                <class>NameSpace_ModuleName_Model</class>
            </namespace>
        </models>
        <events>
            <checkout_cart_product_add_after>
                <observers>
                    <update_qty_on_product_add_to_cart>
                        <type>singleton</type>
                        <class>NameSpace_ModuleName_Model_Observer</class>
                        <method>updateQty</method>
                    </update_qty_on_product_add_to_cart>
                </observers>
            </checkout_cart_product_add_after>
        </events>
    ............
    </global>
</config>

Now, your NameSpace/ModuleName/Model/Observer.php

<?php
class NameSpace_ModuleName_Model_Observer
{
    public function updateQty(Varien_Event_Observer $observer)
    {
       $item = $observer->getEvent()->getQuoteItem();
          $x= $item->getQty();
          $minValue = 8;
          if ($x>= $minValue) { 
             Mage::log('Proceed with number: '.$x, null, 'custom-log.log'); //check in var/log folder  after product adding to cart
          }
          else {
          $x = 8;
             Mage::log('Minimum number is: '.$x, null, 'custom-log.log');
          }
          $item->setQty($x)->save();
    }
?>

Check if file custom-log.log is created in var/log folder after you add product to cart. If it is then your event is firing.

Hope this helps.