Magento built-in Qty Increments is a nice set of functionality. Simple, but effective. It forces user to buy specific product in defined Quantities of X. The problem is that it can only be set globally, for all websites / stores. How to change this? Let’s dive in.

Global / per store?

Normal settings with built-in Qty Increments allow only Global setting. No specific settings for B2B or B2C website.

Magento - Qty Increments - global

Magento – Qty Increments – global

Qty Increments – nice error msg and validation

Magento built-in Qty Increments functionality also support nice error msg if user tries to order different Quantity then specified in Inventory settings.

Magento - Qty Increments - Error Msg

Magento – Qty Increments – Error Msg

Why we want to over-come global setting? Because, we want to enable Qty Increments only for B2B website, but not for B2C. This can not be done as attribute is specified as global. There are modules / extension which solves this, but it didn’t work well or shop.ekwb.com, some MySQL problems. No time to solve this, let’s go to the next solution.

Bundle product. Will this solve the problem?

Magento - bundle product - multiple quantites

Magento – bundle product – multiple quantites

… not quite. The problem is that the new Bundle product has new SKU code, which does not fit quite right at shop.ekwb.com as they would need to create additional SKU/Ident in Accounting system, also problems with stock and so on. Not good one.

What’s left? As always, Magento provides nice options to over-ride base functionality without too much. Two files. app/code/local/Optiweb/StockIncrementQty.php and config.xml. What’s in them?

Magento - StockIncrementQty - overwrite

Magento – StockIncrementQty – overwrite

config.xml first!

Simple. We define that we want to overwrite Item.php (Product – Item).

                    Optiweb_StockIncrementQty_Model_Stock_Item




StockIncrementQty.php next!

Simple, but effective. Bravo Janez @Optiweb. We create two new attributes (manually in Administration), ow_enable_qty_increments and ow_qty_increments and set them “per store”. In code, we just copy paste the code from original StockIncrementQty.php file and change the default attributes “enable_qty_increments” and “qty_increments” to “ow_” prefix (ow stands for OptiWeb!). That’s it.

Rok Meglič

You won’t find Rok in our offices anymore, but we know that no matter where he is now, he is doing a phenomenal job. We’ve kept a piece of them with us as a memory. :)