Page 1 of 1

Product Quantity Update from flat file [V1.3.2]

PostPosted: Tue Nov 17, 2009 11:30 am
by Pete
Update quantity in product table from a csv flat file.
For updating quantities from warehouse/shop inventory system as required such as daily or less.

Adds an item to the catalog menu. To upload and report back the success of uploading product quantities from a csv flat file. This is to allow daily or more frequent updates of quantities where inventory is controlled by another systems such as a pos system in a shop, that controls other sales and purchases. The flat file has to be generated as csv format using model number and quantity that is comma delimited. If this is not possible direct from the shop/warehouse inventory system then usually a report can be generated for use in Excel or OpenOffice that can run a routine to clean up the data and produce a csv file for updating.

The model number is used as a unique product identifier or SKU to match that of the warehouse system. In MySQL I have set the model number in products table as unique.

In the model file I have commented out a statement to allow updating of product options. I have changed the product options value table to include a unique model number and quantity for the option to allow a product as long sleeve shirt in large to directly relate back to the item on the shelf. This is a different modification.

Download from: http://www.opencart.com/index.php?route=contribution/contribution/info&category_id=1&contribution_id=294

Re: Product Quantity Update from flat file [V1.3.2]

PostPosted: Tue Feb 23, 2010 9:13 pm
by airetechit
Hi has anyone managed to get this module working with 1.3.4?

I installed it following the instructions (yes I know it says 1.3.2) and get the following error:

Code: Select all
Parse error: syntax error, unexpected '}' in /public_html/store/admin/model/tool/inventory_update.php on line 18


By any chance at all has someone found why it don't work with 1.3.4 or can at least give me a shove in the right direction...?

Re: Product Quantity Update from flat file [V1.3.2]

PostPosted: Wed Feb 24, 2010 6:54 pm
by The Alchemist
With this MOD can you add new products into inventory as well.

Re: Product Quantity Update from flat file [V1.3.2]

PostPosted: Fri Feb 26, 2010 1:53 pm
by airetechit
To add new products use: viewtopic.php?f=23&t=9600

Anyone managed to figure out for 1.3.4 yet? I'm still trying to figure it out, if I find out will post here.

Re: Product Quantity Update from flat file [V1.3.2]

PostPosted: Fri Mar 05, 2010 1:40 pm
by Pete
airetechit wrote:Anyone managed to figure out for 1.3.4 yet? I'm still trying to figure it out, if I find out will post here.

Sorry missed updating this for 1.3.4 and went straight to 1.4.0. so I do not have an environment to update and test this MOD.
Main difference I think between 1.3.2 and 1.3.4 is the rendering structure. In the file admin/controller/tool/inventory_update.php before validation the rendering instruction should read like this.
Code: Select all
      
$this->data['action'] = $this->url->https('tool/inventory_update');
$this->template = 'tool/inventory_update.tpl';
$this->children = array(
   'common/header',   
   'common/footer'   
   );
      
$this->response->setOutput($this->render(TRUE), $this->config->get('config_compression'));
}
   
private function validate() { .........


Hope this helps.

If using v1.4.0 then http://www.opencart.com/index.php?route=contribution/contribution/info&category_id=1&contribution_id=294

Re: Product Quantity Update from flat file [V1.3.2]

PostPosted: Fri Mar 05, 2010 2:56 pm
by airetechit
Thanks, well now instead of just a blank page it loads up the content (i.e upload form and text, from inventory tpl?) but it does not load the header or footer. Nor does it display a submit button.

I can provide login details to our FTP Server etc as the store is not yet live.

Re: Product Quantity Update from flat file [V1.3.2]

PostPosted: Fri Mar 05, 2010 5:04 pm
by Pete
Ok. If you edit the inventory_upload.tpl and add as the first line
<?php echo $header; ?>

and as the last line of the file
<?php echo $footer; ?>

this should include those two variables.

Re: Product Quantity Update from flat file [V1.3.2]

PostPosted: Fri Mar 05, 2010 8:03 pm
by airetechit
It throws this warning out "The following lines of data is of incorrect type or format and could not be updated:"

However it actually works and updates the quantitys! Thank you so much!!! :)

Re: Product Quantity Update from flat file [V1.3.2]

PostPosted: Sat Mar 06, 2010 9:45 am
by Pete
airetechit wrote:It throws this warning out "The following lines of data is of incorrect type or format and could not be updated:"

You should have a success message at the top with the number of records updated.
Then if any of the lines in the csv file could not be matched you should receive the warning with the individual records below.
When I wrote this tool I used the model number as the sku to match back to the warehouse and as such this field could not be null, had to be unique and alphanumeric so could easily be converted to a barcode.
If you have problems matching the model number in the csv with the database it could be due to characters used in model as this is escaped before comparing to db. You can try in the model/inventory_update.php changing
Code: Select all
     $this->db->query("UPDATE " . DB_PREFIX . "product SET quantity = '" . $this->db->escape($quantity) . "' WHERE model = '" . $this->db->escape($model) . "'");
TO
     $this->db->query("UPDATE " . DB_PREFIX . "product SET quantity = '" . $this->db->escape($quantity) . "' WHERE model = '" . $model. "'");