I'm trying to create a shopping cart rule where free shipping will be given to certain products provided they have an inventory qty greater than 1.

Quantity (qty) is not a visible attribute in the attributes manager so I cant set it to use for promotion rules.

How do you enable the attribute inventory qty to be available for shopping cart rules?

1 Answer 1


Well if it's not too necessary for you to have a custom attribute for checking inventory of product(in catalog not cart) in Magento then, you can also achieve this using an event-observer.

You just have to observe event salesrule_validator_process this will fire just before the rule is applied, and with this you can check if the product's inventory meets your criteria(greater than 1) than only the rule will be validated to true.

Just create an observer like below: app/etc/modules/Company_Module.xml:

<?xml version="1.0"?>


<?xml version="1.0"?>

app/code/local/Company/Module/Model/Observer.php like below:

class Company_Module_Model_Observer extends Varien_Event_Observer {
    public function checkInventory($observer) {
        $quoteItems = $observer->getEvent()->getQuote()->getAllItems();
        foreach($quoteItems as $item):
            $productId = $item->getProductId();
            $_product = Mage::getModel('catalog/product')->load($productId);
            $stock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product);
            if(//Your product id or category condition) {
                if($stock->getQty() > 1.0000) {
                    //Do you stuff here

Refer below links for more info.

What observer need to use for NO-COUPON code apply option in magento?


Hope this helps you out.

  • If you still didn't got a way to do this, I have updated my answer with code example, check it.
    – Vicky Dev
    Jan 8, 2016 at 17:57
  • The module is a nice touch but ultimately your comment about custom attribute is what gave me the idea to do just that and have the stock replicated there, Thank you!
    – SR_Magento
    Jan 8, 2016 at 18:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.