Community Forums

Product Quantity Update from flat file [V1.3.2]

Community created contributions & mods for OpenCart 1.x

Product Quantity Update from flat file [V1.3.2]

Postby Pete » Tue Nov 17, 2009 11:30 am

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
Image
Web Design http://www.wadiam.com

OpenCart reference site: http://www.thenurseryshop.com
User avatar
Pete
 
Posts: 18
Joined: Fri May 22, 2009 3:38 pm
Location: Oxfordshire

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

Postby airetechit » Tue Feb 23, 2010 9:13 pm

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...?
Best Regards,
David Catherall,
AireTech IT.
airetechit
 
Posts: 69
Joined: Thu Feb 04, 2010 5:46 pm
Location: Goole, United Kingdom

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

Postby The Alchemist » Wed Feb 24, 2010 6:54 pm

With this MOD can you add new products into inventory as well.
User avatar
The Alchemist
 
Posts: 202
Joined: Sun Nov 22, 2009 3:04 am

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

Postby airetechit » Fri Feb 26, 2010 1:53 pm

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.
Best Regards,
David Catherall,
AireTech IT.
airetechit
 
Posts: 69
Joined: Thu Feb 04, 2010 5:46 pm
Location: Goole, United Kingdom

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

Postby Pete » Fri Mar 05, 2010 1:40 pm

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
Image
Web Design http://www.wadiam.com

OpenCart reference site: http://www.thenurseryshop.com
User avatar
Pete
 
Posts: 18
Joined: Fri May 22, 2009 3:38 pm
Location: Oxfordshire

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

Postby airetechit » Fri Mar 05, 2010 2:56 pm

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.
Best Regards,
David Catherall,
AireTech IT.
airetechit
 
Posts: 69
Joined: Thu Feb 04, 2010 5:46 pm
Location: Goole, United Kingdom

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

Postby Pete » Fri Mar 05, 2010 5:04 pm

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.
Image
Web Design http://www.wadiam.com

OpenCart reference site: http://www.thenurseryshop.com
User avatar
Pete
 
Posts: 18
Joined: Fri May 22, 2009 3:38 pm
Location: Oxfordshire

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

Postby airetechit » Fri Mar 05, 2010 8:03 pm

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!!! :)
Best Regards,
David Catherall,
AireTech IT.
airetechit
 
Posts: 69
Joined: Thu Feb 04, 2010 5:46 pm
Location: Goole, United Kingdom

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

Postby Pete » Sat Mar 06, 2010 9:45 am

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. "'");
Image
Web Design http://www.wadiam.com

OpenCart reference site: http://www.thenurseryshop.com
User avatar
Pete
 
Posts: 18
Joined: Fri May 22, 2009 3:38 pm
Location: Oxfordshire


Return to Contributions

Who is online

Users browsing this forum: Alexa [Bot], Ask Jeeves [Bot], Daniel, dramony, hdg, panzerknacker and 10 guests