i have a problem with the configuration of the stock, im explain: I need limit the product max qty per customer, the shop need sells certain qty of products per customer, this shop have 40 customers and need distribute the general stock to each customer, how i can do it?, i hope can help me guys! thanks for ur time! have a great day!

  • So each client is only allowed to purchase 1/40th of the stock? And these clients are logged in I presume? Commented Nov 29, 2014 at 19:01
  • Yes thats right Sander!, and yes all clients log in. Commented Nov 29, 2014 at 19:30

2 Answers 2


To restrict the qty use the setting Maximum Qty Allowed in Shopping Cart to 1

enter image description here

If you want to additionally check for previous orders of this item and prevent them being added to the cart you could solve this similar to my answer here https://magento.stackexchange.com/a/9606/9

And then in your observer class


class Fooman_Example_Model_Observer
    public function catalogProductTypePrepare($observer)
        $customerId = Mage::getSingleton('customer/session')->getCustomerId();
        $product = $observer->getEvent()->getProduct();
        //Add code here to look up previous orders
            Mage::throwException('You can only buy this product once.');
  • Thanks for u help, but i need do it with each customer, you post a different solution than i need, i need make the same but not in shopping cart, if not for each customer. i need restrict limit of products bought per costumer, if i have 100 articles on stock spread 10 articles per customer of total of the stock, you got it? Commented Nov 30, 2014 at 1:45

tried this module as base for developing a module ?


the module limits the max saled qty per customer to xx% of current stock.


If you need this feature per customer, you could add custom customer attribute:


$installer = $this;


$setup = new Mage_Eav_Model_Entity_Setup('core_setup');

$entityTypeId     = $setup->getEntityTypeId('customer');
$attributeSetId   = $setup->getDefaultAttributeSetId($entityTypeId);
$attributeGroupId = $setup->getDefaultAttributeGroupId($entityTypeId, $attributeSetId);

$installer->addAttribute("customer", "customattribute",  array(
    "type"     => "varchar",
    "backend"  => "",
    "label"    => "Custom Attribute",
    "input"    => "text",
    "source"   => "",
    "visible"  => true,
    "required" => false,
    "default" => "",
    "frontend" => "",
    "unique"     => false,
    "note"       => "Custom Attribute"


        $attribute   = Mage::getSingleton("eav/config")->getAttribute("customer", "customattribute");

    '999'  //sort_order


        $attribute->setData("used_in_forms", $used_in_forms)
                ->setData("is_used_for_customer_segment", true)
                ->setData("is_system", 0)
                ->setData("is_user_defined", 1)
                ->setData("is_visible", 1)
                ->setData("sort_order", 100)



 <?xml version="1.0"?>

and edit app\code\community\Tom\PercentStock\Model\Item.php

 * Retrieve Maximum Qty Allowed in Shopping Cart data wraper
 * @return float
public function getMaxSaleQty() {
    if($this -> getUseConfigMaxSaleQty()) {
        $customerSession = MAge::getSingleton('customer/session');
        if(Mage::getStoreConfig(self::XML_PATH_ENABLE_PERCENT && $customerSession->isLoggedIn())) {
            $customer = $customerSession->getCustomer();

            return (float) $customer->getCustomattribute();
        return (float)Mage::getStoreConfig(self::XML_PATH_MAX_SALE_QTY);
    return (float)$this -> getData('max_sale_qty');

In this case the value you entered in the custom attribute is returned as maximum amount of sold items per customer.

  • I see this module but in the overview only appears it: " This Module allows you to dynamically change the maximum Qty Allowed in Shopping Cart by percent of current Stock". It only modify the shopping cart rules, not work for each customer to define some stock. Commented Nov 30, 2014 at 1:39
  • I have installed that plugin but it not show the same rules if it show on magentoconect review, why?, can help me please thanks! Commented Nov 30, 2014 at 13:30
  • could you provide a Screenshot or a list of Options you can see in backend?
    – tomtone
    Commented Nov 30, 2014 at 13:41
  • And can help me to explain how configure the steps of you show me on your post?, im not have much experience to create modules. Thanks again for u help! Commented Nov 30, 2014 at 13:42
  • Here the screenshot! oi57.tinypic.com/2mcc6r7.jpg Commented Nov 30, 2014 at 13:45

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.