Beluga Posted March 14, 2014 Share Posted March 14, 2014 I tested the new options to CSV import products to warehouse. Whenever I have the three new options (Advanced Stock Management, Depends on stock, Warehouse) enabled, I get this: [PrestaShopException]Property Stock->price_te is not validat line 837 in file classes/ObjectModel.php So it somehow stumbles on the price excluded calculation. Yet the first two products in the CSV get imported. All import fine, if I don't have the warehouse stuff on. The two products that do get imported do not, however, get their quantities into the warehouse. I would very much like this to happen. Then I wouldn't have to use this core hack anymore. Can you guys test the import and see, if you run into the same error? Link to comment Share on other sites More sharing options...
indesign47 Posted March 14, 2014 Share Posted March 14, 2014 Hello, Test and works on PS 1.6.4 RC. Example of your csv file ? Best regards Link to comment Share on other sites More sharing options...
indesign47 Posted March 14, 2014 Share Posted March 14, 2014 Hello, Check if you version contains the fix of Greg https://github.com/PrestaShop/PrestaShop/commit/dc9025c59132781fc8c21755454cc78407b14677 Best regards Link to comment Share on other sites More sharing options...
Beluga Posted March 15, 2014 Author Share Posted March 15, 2014 (edited) Thanks for testing. I'll try the fix later today (I have to install 1.6 on my home computer because I tested at work). Can you say how the quantity import to warehouse works exactly? I had modified the import code so that I could import absolute values to the warehouse (replacing the quantity) and not "add to stock". This is my preferred way of working, synchronizing the webshop stock with our local inventory. So how does it behave, if you update a product with the import and use a different quantity? Does it add or replace the quantity in the warehouse? Edited March 15, 2014 by Beluga (see edit history) Link to comment Share on other sites More sharing options...
indesign47 Posted March 15, 2014 Share Posted March 15, 2014 (edited) Hello, Can you say how the quantity import to warehouse works exactly? 'advanced_stock_management' => array( 'label' => $this->l('Advanced Stock Management'), 'help' => $this->l('Enable Advanced Stock Management on product (0 = No, 1 = Yes)') ), 'depends_on_stock' => array( 'label' => $this->l('Depends on stock'), 'help' => $this->l('0 = Use quantity set in product, 1 = Use quantity from warehouse.') ), 'warehouse' => array( 'label' => $this->l('Warehouse'), 'help' => $this->l('ID of the warehouse to set as storage.') • Quantity = 100 Quantity available in stock management if depends on stock = 1 Quantity want to specify available quantities manually if depends on stock = 0 So how does it behave, if you update a product with the import and use a different quantity? Does it add or replace the quantity in the warehouse? It add quantity Best regards Edited March 15, 2014 by indesign47 (see edit history) Link to comment Share on other sites More sharing options...
Beluga Posted March 15, 2014 Author Share Posted March 15, 2014 @indesign47: thanks. To PrestaShop core devs: What about having the option to absolutely update stock quantities in the warehouse? Currently I use this modification: if(isset($info['warehouse_reference'])&&!empty($info['warehouse_reference'])) { $query = new DbQuery(); $query->select('id_warehouse'); $query->from('warehouse'); $query->where("reference LIKE '".$info['warehouse_reference']."'"); $query->where('deleted = 0'); $warehouse_csv = new Warehouse((int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($query)); if($warehouse_csv>0) { $manager = StockManagerFactory::getManager(); $quantity_in_stock = $manager->getProductPhysicalQuantities((int)$product->id, 0, array($warehouse_csv), false); $stockmovement = StockMvt::getLastPositiveStockMvt((int)$product->id, 0); if ($stockmovement != false) { $last_sm_currency = new Currency((int)$stockmovement['id_currency']); if (Validate::isLoadedObject($last_sm_currency)) $last_unit_price = Tools::displayPrice((float)$stockmovement['price_te'], $last_sm_currency); } else { $last_unit_price = (int)$info['unit_price']; } if((int)$info['quantity_add_warehouse'] > $quantity_in_stock) { $quantity_difference = ((int)$info['quantity_add_warehouse'] - $quantity_in_stock); $manager->addProduct((int)$product->id,0,$warehouse_csv,$quantity_difference,1,$last_unit_price); } else { $quantity_difference = ($quantity_in_stock - (int)$info['quantity_add_warehouse']); $manager->removeProduct((int)$product->id,0,$warehouse_csv,$quantity_difference,1); } Warehouse::setProductLocation((int)$product->id,0,$warehouse_csv->id,""); StockAvailable::synchronize((int)$product->id); } } You can see there that I calculate the quantity difference. 1 Link to comment Share on other sites More sharing options...
Samar Rizvi Posted December 7, 2014 Share Posted December 7, 2014 Hi @Beluga, The problem there is that when you keep the wholesale price as 0 or keep it empty, it is converted 0.000001 and then validated. During validation it is probably converted to string, and hence the value becomes 1.0E-6 rather than 0.000001 due to which $price_te becomes invalid. Will look into the purifier section of tools. 3 1 Link to comment Share on other sites More sharing options...
moy2010 Posted January 1, 2015 Share Posted January 1, 2015 Hi, Beluga and Samar. Did you manage to get it working so that it imports the overall quantities available at the warehouse? Thanks in advance . Link to comment Share on other sites More sharing options...
Beluga Posted January 1, 2015 Author Share Posted January 1, 2015 Hi, Beluga and Samar. Did you manage to get it working so that it imports the overall quantities available at the warehouse? Thanks in advance . I haven't tried yet.. still running 1.5.x in production. 1.6.12 should have a fix for pack & adv. stock management interaction, so I should get back to testing in the near future. 1 Link to comment Share on other sites More sharing options...
Recommended Posts