tuvika Posted March 4, 2014 Share Posted March 4, 2014 (edited) NOTE: PS 1.5.6.2 I'm going to try to sum up my spanish post version, because I'm not getting hints at all. I'm writing a PS module to sync my PS store with an external product catalog using a webservice. It was originaly designed to work in the vanilla single store installation, but the project finally needs to turn in a multistore shop. In the single store version the module just works fine using this class::function to manage stocks: StockAvailable::setQuantity(Tools::getValue((int)$producto->id), '', Tools::getValue(10000)); But when I try to use the same script on a multistore PS, I get a PHP Fatal Error message, but no further description about what produced the fail (lines of module php code or whatever and I'm using a try - catch sentence with an error handler set that worked fine during the rest of development). Looking in the PS source code for some kind of solution, I saw that the previous setQuantity function was accepting a fourth parameter which is used to identify the store that will receive the stock quantity update: StockAvailable::setQuantity(Tools::getValue((int)$producto->id), '', Tools::getValue(10000), (int)Configuration::get('PS_SHOP_DEFAULT')); But this solution neither works I'm not sure if we're running out of possibilities to make it work properly in the PS way and I should use some SQL queries to insert/update the stock quantities, anyway I'm not sure what tables I should update in a multistore flavour PS to get it working. Sorry for the "brick" Regards! Edited March 22, 2014 by tuvika (see edit history) Link to comment Share on other sites More sharing options...
tuvika Posted March 22, 2014 Author Share Posted March 22, 2014 Finally I found a solution for this case, as We're working with a multistore PS >=1.5 I wasn't using the shop context in a proper way, and the code linea for modifying stock quantities wasn't correct. Furthermore I needed a new selectbox on my module config to add the possibilite to add products and stocks quantities to a specific shop chosen by the user. Before We can add products and stock quantities, We need to set up the correct shop context: Shop::setContext(Shop::CONTEXT_SHOP, $this->tiendaps); And the fix on the stock setquantity line, is like follows: StockAvailable::setQuantity((int)$producto->id, null, 10000, (int)$this->tiendaps); Regards! Link to comment Share on other sites More sharing options...
Totti Posted December 22, 2015 Share Posted December 22, 2015 You can find the product code by using the code sku ? I should look for a product with sky and update the quantity.I must also take account of the attributes. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now