close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

I need to update all prices and dimensions with a batch process

Thread began 3/14/2012 4:32 am by mrs | Last modified 3/16/2012 5:05 am by mrs | 1288 views | 3 replies

mrs

Don't worry, I've just twigged that I hadn't got the WHERE clause in place.

If any body is interested in this capability, then here is the process to update products in your products table by batch processing from something like a CSV file.

1. Create an import table. The code for my import table is:

DROP TABLE IF EXISTS `_import_products`;

CREATE TABLE `_import_products` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`ProductSKU` varchar(50) DEFAULT NULL,
`ProductPrice` float(12,2) DEFAULT NULL,
`ProductWeight` float(12,2) DEFAULT NULL,
`ProductWidth` decimal(12,4) DEFAULT NULL,
`ProductHeight` decimal(12,4) DEFAULT NULL,
`ProductLength` decimal(12,4) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=2684 DEFAULT CHARSET=latin1;


2. Import the updated prices to the import table (I use Sequel Pro to handle imports etc).


3. Merge the two tables with this query:

UPDATE ps4_products
LEFT JOIN _import_products ON (_import_products.ProductSku = ps4_products.ProductSKU)
SET ps4_products.ProductPrice = _import_products.ProductPrice, ps4_products.ProductWeight = _import_products.ProductWeight, ps4_products.ProductWidth = _import_products.ProductWidth, ps4_products.ProductHeight = _import_products.ProductHeight, ps4_products.ProductLength = _import_products.ProductLength
WHERE _import_products.ProductSku = ps4_products.ProductSKU;


Obviously, this works for my import table, and I have added fields to the products table to allow for product dimensions. It will need to be adjusted to suit your requirement.

HTH

Mat

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...