Christiaan_01 Posted December 30, 2015 Share Posted December 30, 2015 Hi all, I was wondering if someone knows a fix/improvement for the following issue. The normal way Prestashop handles a supply order import via csv is by identifying products by ID_product. My issue is that it would be much easier to identify products by supplier_reference, since I always get a list from my supplier. To deal with this issue I always spend a lot of time to match the supplier_reference to the product ID in Excel. Does anyone know how to identify products by supplier_reference (or even reference) for the supply order detail csv import? I've been fiddling around in the AdminImportController.php, but couldn't find a solution. Hope someone can help. Thanks, Christiaan Link to comment Share on other sites More sharing options...
gabdara Posted December 30, 2015 Share Posted December 30, 2015 Do you mean importing products using a csv file from your supplier through BO > Advanced Parameters > CSV Import? If so, there is an option called Use product reference as key that you could use if your products reference matches the ones from your supplier. Link to comment Share on other sites More sharing options...
Christiaan_01 Posted December 30, 2015 Author Share Posted December 30, 2015 Thanks for your reply. Unfortunately that option is only available while importing products. Not for importing supply order details. Link to comment Share on other sites More sharing options...
gabdara Posted December 30, 2015 Share Posted December 30, 2015 Sorry if I don't understand your question. Are you using a module to import supply order details through CSV? In a default installation of 1.6 I don't see this option, there is only import for Categories, Products, Combinations, Customers, Addresses, Manufacturers, Suppliers and Alias. Link to comment Share on other sites More sharing options...
Christiaan_01 Posted December 30, 2015 Author Share Posted December 30, 2015 (edited) No, I'm using standard CSV import like you said: BO > Advanced Parameters > CSV Import Probably you have not enabled Advanced Stock Management in your backoffice, so the supply order option doesn't show up. Edited December 30, 2015 by Christiaan_01 (see edit history) Link to comment Share on other sites More sharing options...
RogueWaveLimited Posted December 30, 2015 Share Posted December 30, 2015 Can you use a supplier id field with the import? Then the imported products will be for that supplier. [As always you should test this with one or two products first] Link to comment Share on other sites More sharing options...
Christiaan_01 Posted December 30, 2015 Author Share Posted December 30, 2015 Hi Richard, There's no supplier field in the supply order detail import. I don't see how that would relate to my issue. Link to comment Share on other sites More sharing options...
gabdara Posted December 30, 2015 Share Posted December 30, 2015 I've found it. I will try to help you with this but it will require some code editing and some tests on your behalf. The main idea is to use the field Product ID as product reference and also maintain the current functionality with product id. So if you put in column Product ID one row with product reference and the next with product id, both should work. Before you start editing and testing you should make a backup! On file YOUR_PRESTA/controllers/admin/AdminImportController.php add this function somewhere: public function getProductInfoByReference($product_reference) { $query = new DbQuery(); $query->select('p.id_product, pa.id_product_attribute'); $query->from('product', 'p'); $query->leftJoin('product_attribute', 'pa', 'pa.id_product = p.id_product'); $query->where('(p.reference = \'' . pSQL($product_reference) . '\' AND pa.default_on = 1) OR pa.reference = \'' . pSQL($product_reference) . '\''); return Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($query); } Then edit the lines 3223-3227 into: if (is_numeric($info['id_product'])) { // is product id $id_product = (int) $info['id_product']; $id_product_attribute = isset($info['id_product_attribute']) ? (int) $info['id_product_attribute'] : 0; } else { // is product reference $prod_info = $this->getProductInfoByReference($info['id_product']); $id_product = (int) $prod_info['id_product']; $id_product_attribute = (int) $prod_info['id_product_attribute']; } Now test your Supply Order Details import with product reference instead of id. Note These changes should be done into an override, otherwise at an update you could loose them. But for starters I think is more important for you to see it working, then you could move the changes into an override. Link to comment Share on other sites More sharing options...
Christiaan_01 Posted December 30, 2015 Author Share Posted December 30, 2015 Hi Gabdara, Thank you very much for your effort. Unfortunately I get this error: 867. 868. $message = $this->validateField($field, $this->$field); 869. if ($message !== true) 870. { 871. if ($die) 872. throw new PrestaShopException($message); 873. return $error_return ? $message : false; 874. } 875. } 876. 877. return true; ObjectModelCore->validateFields - [line 278 - classes/ObjectModel.php] ObjectModelCore->getFields - [line 486 - classes/ObjectModel.php] ObjectModelCore->add - [line 210 - classes/stock/SupplyOrderDetail.php] - [2 Arguments] SupplyOrderDetailCore->add - [line 3162 - controllers/admin/AdminImportController.php] AdminImportControllerCore->supplyOrdersDetailsImport - [line 3392 - controllers/admin/AdminImportController.php] AdminImportControllerCore->postProcess - [line 171 - classes/controller/Controller.php] ControllerCore->run - [line 390 - override/classes/Dispatcher.php] Dispatcher->dispatch_16 - [line 122 - override/classes/Dispatcher.php] Dispatcher->dispatch - [line 54 - admin/index.php] Link to comment Share on other sites More sharing options...
Christiaan_01 Posted December 30, 2015 Author Share Posted December 30, 2015 As a matter of fact I found a solution. I make use of StoreCommander (separate module) and apparently it supports this functionality. I don't need the fix but maybe for other people this functionality might be useful. Thanks for all contributions. 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