1

Currently, for every product the attribute "Inventory" > "Maximum Qty Allowed in Shopping Cart" is defined in global scope for one article.

How can I change this scope to have the maximum quantity in the product defined for each webpage?

Everything I find is about changing the system configuration but does not affect the article: product[stock_data][max_sale_qty]

enter image description here

2 Answers 2

2

This field is stored in the table cataloginventory_stock_item which does not have a store_id field - so you basically could extend this table and adding a store ID.

Then you have to modify \Mage_CatalogInventory_Model_Stock_Item::getMaxSaleQty via a model rewrite.

In case you have the same max sale qty for all items of one store, it should work if you just modify the system configuration for max_sale_qty in app/code/core/Mage/CatalogInventory/etc/system.xml (also in a custom module with the same XML node)

 <max_sale_qty translate="label"> <label>Maximum Qty Allowed in Shopping Cart</label> <frontend_type>text</frontend_type> <validate>validate-number</validate> <sort_order>4</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>1</show_in_store> </max_sale_qty> 
0

I ended up writing a module that overwrites getMaxSaleQty() as needed. Ignoring the config value.

app/code/local/My/Modul/Model/Stock/Item.php

class My_Modul_Model_Stock_Item extends Mage_CatalogInventory_Model_Stock_Item { public function getMaxSaleQty() { $max = parent::getMaxSaleQty(); if (Mage::app()->getStore()->getStoreId() == 1) { if ($this->getProduct()->getFinalPrice() == 0) { $max = 1; } } return $max; } } 

and in app/code/local/My/Modul/etc/config.xml

<global> <models> <cataloginventory> <rewrite> <stock_item>My_Modul_Model_Stock_Item</stock_item> </rewrite> </cataloginventory> </models> </global> 

You could also add a custom attribute to control this.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.