Re: Adding product name

david.houlder's picture
Offline
Joined: 05/29/2010
Juice: 115
Re: Adding product name

Hi Mark,

First you need to modify _uc_stock_update_export_product_options() to write the title field to the outpuit file. Something like this should do the trick (changes in bold):

function _uc_stock_update_export_product_options($csv_filename, $headings) {
  return _uc_stock_update_export(
             array('nid', 'title', 'oid', 'model', 'name', 'cost', 'price'),

             "SELECT {node}.nid, title, oid, model, ".
             "{uc_attribute_options}.name, ".
             "{uc_product_options}.cost, {uc_product_options}.price ".
             "FROM {node} INNER JOIN {uc_product_options} USING (nid) ".
             "INNER JOIN {uc_products} USING (vid) ".
             "INNER JOIN {uc_attribute_options} USING (oid) ".
             "ORDER BY model",

             $csv_filename, $headings);
}

Once you've done that, you have to adjust the array returned by _uc_stock_update_formats() to cater for the new field. e.g.

      'product-options.csv' =>
      array('_uc_stock_update_export_product_options',
            'product_options',
            t('product option prices'),
            '_uc_stock_update_import_product_options',
            array("PRODUCT_ID",  "product_name", "OPTION_ID",  "sku",
                  "option_name", "Cost", "Price"),
            array(0, 2),
            array(5, 6)
            )
      );

I haven't tested this, but assuming it's free of typos, I suspect it'll work. Let me know if there are any glitches.

Cheers,
David

David Houlder
http://davidhoulder.com

Stock & Price CSV Updater 2 By: david.houlder (80 replies) Sat, 05/29/2010 - 22:48