How to set Minimum Order Quantiy (MOQ) for a categ

2019-07-28 16:51发布

问题:

How to add Minimum Qty Allowed in Shopping Cart for a category.

In Magento (ver. 1.6.2.0) backend, System > Configuration > Inventory > Product Stock Options tab, you can set the 'Minimum Qty Allowed in Shopping Cart' but for Customer Group; not for Category.

We have lots of categories having absolutely different kinds of items and need different MOQs for specified category.

How would I force a minimum of 6 products from the jewellery category and 7 dozen from the bra category?

Thanks, Shaman

回答1:

What you describe would not be natively possible with Magento. Magento natively provides a 1:many relationship with categories and products,

Ie. A product can be in many categories

What you propose would induce a race condition for a product whereby there could be 2 possible critera for a product's inventory controls if the product exists in more than one category.

Eg. If you set Category A to have a MOQ of 6, and Category B to have a MOQ of 10 and Product C exists in both - which rule does it inherit (highest/lowest)?

As a result, this isn't going to be natively possible, but you could build a custom module to achieve it.

Either ...

Via a category->save() observer

You could create a custom attribute for the category - MOQ, then have your module 'listen' to the category save, and iterate through all products accordingly to set the MOQ for said products.

Advantages - More granular control per product, no speed impact/overheads for frontend

Disadvantages - Slow to save category

Or

By modifying the isSaleable() function

You could rewrite the standard function which determines if a product is saleable. In your modified function, check categories of said product, obtain the MOQ (highest/lowest - whichever) then return true; or return false; accordingly.

Advantages - Less administration hanging around, stops having to continually update indexes at a product level needlessly

Disadvantages - Slower to check if product is saleable (frontend would seem slower)


Either way, you need to build a custom module, or seek a professional to make one for you.



标签: magento