I've got all of the technical junk out of the way (unpacking the ZIP archive, importing the XML, parsing the XML into individual product information bits), but I'm really new to LemonStand and I'm not sure the preferred method of saving products to the database.
Here are my goals:
- Import new products into the database[/*]
- Update existing products in the database[/*]
- Delete old products from the database[/*]
The POS system provides an XML dump of new/updated products and products to be removed, as well as categories to be added/updated/removed, and a dump of product-category relationships.
What I'm wondering is this: how do I save the parsed product info, categories, and product-category associations into the DB?
My first instinct was to invoke a Shop_Product() object and save them like that:
$db_product = new Shop_Product(); $db_product->name = $name; $db_product->description = $ldesc; $db_product->short_description = $sdesc; $db_product->url_name = $url; $db_product->price = $price; $db_product->sku = $sku; $db_product->weight = $weight; $db_product->width = $width; $db_product->height = $height; $db_product->depth = $depth; $db_product->meta_description = $meta_description; $db_product->meta_keywords = $meta_keywords; $db_product->enabled = $enabled; $db_product->save();
However, that resulted in the following error:
Quote
Also, due to my lack of familiarity with ActiveRecord, I'm not sure if that will update existing products (I imagine it won't unless I check for the SKU or something similar first).
And, of course, the categories are sort of confusing to me. I looked at the documentation, but I couldn't find a "save product" example. I could probably hack this together, but I figured I'd ask about best practices first. I don't want to break anything. :)
Thanks in advance!

Help
















