jaceks Posted March 10, 2013 Share Posted March 10, 2013 Hi, is any simply coding to handle attribute quantity in PS 1.5.3 this way: when any attribute is bought, the quantity of all of them gets reduced? I'd like to use this feature in the whole shop. Thanks. Link to comment Share on other sites More sharing options...
Mcasey Posted March 10, 2013 Share Posted March 10, 2013 Hi, is any simply coding to handle attribute quantity in PS 1.5.3 this way: when any attribute is bought, the quantity of all of them gets reduced? I'd like to use this feature in the whole shop. Thanks. So lets say you have five products. Product A,B,C,D,E. They are all initialized to a quantity of 5. When you buy, say, product E, all other four products are reduced to 4 as well? Can you explain why you are doing this so I can get a better idea of what you are trying to accomplish? But, yes you would be able to do this as prestashop attributes work through a database. Link to comment Share on other sites More sharing options...
jaceks Posted March 10, 2013 Author Share Posted March 10, 2013 Let's say I've got 10 items, which I can paint myself in 5 different colours (A,B,C,D,E). Customer can choose the colour as an attribute. When he buys 1 item in defined colour, I've got 9 items left in a shop that can be painted any colour depending on next order. Link to comment Share on other sites More sharing options...
Mcasey Posted March 10, 2013 Share Posted March 10, 2013 Let's say I've got 10 items, which I can paint myself in 5 different colours (A,B,C,D,E). Customer can choose the colour as an attribute. When he buys 1 item in defined colour, I've got 9 items left in a shop that can be painted any colour depending on next order. Well, I think what you are trying to do is very simple... If you go into your back-office and you navigate to products, you can edit the quantity of that item to whatever you want.... I think this is what you are trying to do, if not please let me know. Link to comment Share on other sites More sharing options...
jaceks Posted March 11, 2013 Author Share Posted March 11, 2013 To be honest I have no idea how to do this with current PS features. My plan was to put 10 quantities by each colour, and when customer buys 1 item, all colours are reduced by one, because I will have 9 items left in the shop to be panted with any colour. At the moment only one colour is reduced and other stay with number 10. Simillar isue was rised for older versions of PrestaShop. http://www.prestashop.com/forums/topic/43828-combination-quantity/ Link to comment Share on other sites More sharing options...
tomerg3 Posted March 11, 2013 Share Posted March 11, 2013 It's not as simple as that, since you will still be able to all all of them to the cart (IE 10 in red and 10 in blue) before you checkout, which would then create a mess. If you do not need to have connected attributes (IE selection of attribute in group A changes the options in group , or price impacts, you could use http://www.presto-changeo.com/en/attribute-modules/34-attribute-wizard-pro.html That module changes the way combinations work, you will be able to have all the attribute from a single group in one combination, and they will share the stock. Link to comment Share on other sites More sharing options...
jaceks Posted March 11, 2013 Author Share Posted March 11, 2013 It's not as simple as that, since you will still be able to all all of them to the cart (IE 10 in red and 10 in blue) before you checkout, which would then create a mess. True, it might be a disadvantage. If you do not need to have connected attributes (IE selection of attribute in group A changes the options in group , or price impacts, you could use http://www.presto-ch...wizard-pro.html Unfortunately I need a price impact. For those who may need it. I've made these changes in classes/stock/StockAvailable.php under updateQuantity() function (line 432): before $stock_available = new StockAvailable($id_stock_available); $stock_available->quantity = $stock_available->quantity + $delta_quantity; $stock_available->update(); after //each product attribute will be deducted $ids_product_attribute = array(); foreach (Product::getProductAttributesIds($id_product) as $id_product_attribute) $ids_product_attribute[] = $id_product_attribute['id_product_attribute']; foreach ($ids_product_attribute as $id_product_attribute) { $id_stock_available = StockAvailable::getStockAvailableIdByProductId($id_product, $id_product_attribute, $id_shop); $stock_available = new StockAvailable($id_stock_available); $stock_available->quantity = $stock_available->quantity + $delta_quantity; $stock_available->update(); } //original // $stock_available = new StockAvailable($id_stock_available); // $stock_available->quantity = $stock_available->quantity + $delta_quantity; // $stock_available->update(); As I 'm not a php programmer it might need optimization or changes. Link to comment Share on other sites More sharing options...
jaceks Posted March 13, 2013 Author Share Posted March 13, 2013 Previous code didn't reduce quantity of products without attributes, so it should be: after //each product attribute will be deducted if ($id_product_attribute != 0) { $ids_product_attribute = array(); foreach (Product::getProductAttributesIds($id_product) as $id_product_attribute) $ids_product_attribute[] = $id_product_attribute['id_product_attribute']; foreach ($ids_product_attribute as $id_product_attribute) { $id_stock_available = StockAvailable::getStockAvailableIdByProductId($id_product, $id_product_attribute, $id_shop); $stock_available = new StockAvailable($id_stock_available); $stock_available->quantity = $stock_available->quantity + $delta_quantity; $stock_available->update(); } } else { $stock_available = new StockAvailable($id_stock_available); $stock_available->quantity = $stock_available->quantity + $delta_quantity; $stock_available->update(); } //original // $stock_available = new StockAvailable($id_stock_available); // $stock_available->quantity = $stock_available->quantity + $delta_quantity; // $stock_available->update(); 1 Link to comment Share on other sites More sharing options...
Recommended Posts