I need to be able to import data into Ubercart products, and the SKU (model) needs to be the unique ID. This patch makes it possible to assign an Ubercart base field as the unique ID.

I basically just copied and modified the approach this module takes for exposing CCK fields. I'm not sure this is the right way to do it, but at least it is consistent with existing code.

I've only tried it with SKU.

This patch is against 6.x-0.2, not the dev version. I'm not using the dev version on my site.

CommentFileSizeAuthor
node_import_update_ubercart.patch1.84 KBsmscotten

Comments

smscotten’s picture

Status: Active » Needs review
fooby’s picture

can this also be applied to the sub sku from product attributes?

smscotten’s picture

@fooby I'm not even sure how that would work. Do you have multiple products with the same SKU but different product attribute SKUs? Trying to wrap my feeble mind around this but it's not really happening.

fooby’s picture

i manage a shop with about 60 different taxonomy terms for categories. all products have the attribute size
our sku's exists in 2 different variations

xxxxx-xxx-xxx
main-color-size

this variation is used for all products which have a size p.e. t-shirts, hoodies, etc...

xxxxx-xxx
main-color

this variation is used for products without attributes, like sunglasses, screwsets, etc...

for being able to import all in 1 big import we gave products at least 1 attribute, even if the product itself had no variations. products without variations get a subattribute, called "no attribute" which also holds the stock for the product.
only the last 3 digits of every sku are used to distinguish attributes from the main product

so the idea was to make a big import with all data and then later only update the stock by grabbing the sub sku.

our shop only gets new products every six months when season collections come out. being able to use unique sub-skus as identifier would really simplify the daily import.

edit: i know this approach isnt very good, but we have to crawl the manufacturers website. unfortunately the data we get is inconsistent and so we had to merge most product defining aspects to get a csv which is consistent and importable

grimbones’s picture

I tried the patch and it didn't work, so I modified two lines and got the nodes to update using the SKU number.

The original code in the patch is:

     // CCK field as unique identifier
     $IMPORT_UNIQUE_ID_NAME   = 'title';  // Import field that holds the unique identifier
     $IMPORT_UNIQUE_ID_IS_CCK = FALSE;    // Is the identifier a CCK field?
     $IMPORT_UNIQUE_ID_IS_UC  = FALSE;    // Is the identifier an Ubercart field? 

If you want it to read a SKU number you need to set $IMPORT_UNIQUE_ID_IS_UC to TRUE and switch "title" to "model". "model" is the name of the database column that stores the SKU number. Basically you can set it to track any field as long as you use the column name from the database.

Here is the new modified code with the two lines changed:

    // CCK field as unique identifier
    $IMPORT_UNIQUE_ID_NAME   = 'model';  // Import field that holds the unique identifier
    $IMPORT_UNIQUE_ID_IS_CCK = FALSE;    // Is the identifier a CCK field?
    $IMPORT_UNIQUE_ID_IS_UC  = TRUE;    // Is the identifier an Ubercart field?

I don't really know how to make a patch file so if someone could help me that would be great.

smscotten’s picture

Sorry, when I made the patch file, I made it so that using UC fields could be enabled. Yes, $IMPORT_UNIQUE_ID_IS_UC needs be set to TRUE but that's not how I'm guessing the module should be shipped if the patch were rolled in to the module.

'title' for example is in the module and the person configuring the module needs to fill in the correct values.

So the patch works, grimbones. And you did exactly the right configuration. You would have had to change $IMPORT_UNIQUE_ID_IS_CCK to true and change the value of $IMPORT_UNIQUE_NAME if you were configuring for some CCK field to be the unique ID. Everyone that uses node_import_update has to do basically the same editing you did, even without Ubercart fields or the patch applied.

coolestdude1’s picture

Status: Needs review » Closed (fixed)

Implemented along with settings page in dev version.