I am attempting to use the commerce feeds module to import both products and product display nodes as well as relating the product display to multiple child products. Is there any way to do this cleanly?

I have seen:
http://drupal.org/node/1122422#comment-4639566

But unfortunately my data (which I have very little control over) looks like

ProdDisplay1, product1, field1
ProdDisplay1, product2, field2
ProdDisplay1, product3, field3
ProdDisplay2, product4, field4

Is there a way to set up this one to many relationship?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

pcambra’s picture

You should take a look to this patch #1188994: Accumulative product reference mapper that provides a way to accumulate products in displays

BrianLP’s picture

I'm not sure whether I understand this right, but doesn't that work just like importing other multiple values? Use the Feeds Tamper module and the "explode" plugin. Then you can import multiple SKUs as product references for your Product display. (comma separated in one cell of your csv table)

That's how I import multiple taxonomy terms per display.

pcambra’s picture

That slolution works if you can have this data structure:
Display1, SKU1|SKU2|SKU3
Display2, SKU1|SKU2|SKU3

But if you have
Display1, SKU1
Display1, SKU2
Display2, SKU1
Display2, SKU2

You need the accumulative importer as feeds doesn't support this, you'll find a lot more of details in the issue I pasted above.

BrianLP’s picture

I think I don't get the purpose of that. Is it to display product variants in one display each instead of one display with a selector for variants?

Chair > red/green/blue -vs.- red chair / green chair / blue chair

If so, I solved it by preparing all mapping tasks in my spread sheet app. There I have one product table and one display table.

  • Every product gets a "display ID" in which I want it to show up later.
  • Via this ID the products table pulls in the display data (lookup formula). So if I change a display, it is changed in all mapped products.
  • Now I have a complete table with mapped products/displays which I can import with CF.
  • I run two importers, one for the displays and one for the products. Both grab different columns but the SKU as reference.

product 1 - display 1
product 2 - display 1
product 3 - display 1
product 4 - display 2
product 5 - display 2
product 6 - display 2

This is not the solution to the original question but it's the easiest way I have found for me.

liupascal’s picture

@papalapapp

With this solution do you end up with having
display 1 : refers to product 1, 2, 4
display 2 : refers to product 4, 5, 6 ?

If yes can you please export a little csv example (a few lines) and the export of your importer configuration ?

Many thanks

BrianLP’s picture

Status: Closed (fixed) » Active
FileSize
69.28 KB

Well, it isn't technically the way that the display is refering to multiple products. The referral is done before the import and written in that table which is importet then.

So inside drupal, instead of referring, the display is imported as often as needed. I find it hard to explain but actually it's quite easy. The hardest part is doing the formulas in the spreadsheet. You can use excel or any other spreadsheet app.

In the image below, I actuall only edit the first two tables "Displays" and "Products". The import csv table is a bunch of formulas referencing the data to the products and displays. Once set up, no more editing needed. Same for the importers.

So if there are changes or new products, I just do a csv-export of the table in the middle and run the importers.

If Commerce could map it internally, there wouldn't be a need for a joint csv table with formulas. They could be handled separately.

BrianLP’s picture

rfay’s picture

I demonstrate how to do this with feeds tamper in the last screencast on http://www.drupalcommerce.org/node/467

pcambra’s picture

Status: Active » Fixed

Let's mark this as fixed as many solutions and information has been provided, feel free to reopen if necessary.

Thanks to everyone!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Robert21’s picture

We have a similar situation as shown above #7 (Posted by papalapapp on December 14, 2011 at 12:45am). Is the only option to importira through feeds tamper? I have for example a product with 30 different variations and all together 6500 products.
example(structures):
PRODUCTCODE;MODELCODE;MODELNAME;DESCRIPTION;COMPOSITION;CATEGORY;GENDER;SIZE;COLOR;COLLECTION;SUBCOLLECTION;PRODUCTIMAGE;MODELIMAGE

PRODUCTCODE = unique
MODELCODE = different product variations (Alphanumeric)

How should I do it?

vbard’s picture

Version: 7.x-1.2 » 7.x-1.3
Component: User interface » Documentation

Hi!
I have same question as #11, does anyone has a solution?

Summit’s picture

Hi,
I try to get it clear here: https://drupal.org/comment/8138947#comment-8138947
Greetings, Martijn

redhatusr’s picture

Issue summary: View changes
FileSize
47.49 KB

I am trying to import multiple products into one product display node following papalapapp suggestions at #6 and #7 but something that I don't understand creates many Product Displays with one Product instead of one Product Display with many Products

does anyone know what I am doing it wrong?

commerce feeds multi

Also i try in Node processor to map SKU -> GUID (insted of ID -> GUID) with the same results

Summit’s picture

Hi,
I am still struggling with this also as remark here (https://drupal.org/node/2113575#comment-8162539), may be this helps you:
First time you use "Commerce Product processor", second - "Node processor".

Would love to see you succeed and please explain than how and what you used.

greetings,
Martijn

Pravin Ajaaz’s picture

I am also Struggling with the same as #14... since Title is not unique it creates multiple displays... Have anyone found the way to do it... Please let me know...

BrianLP’s picture

Maybe the trick is that I set the SKU also as the GUID additionally as to the SKU mapping. These screenshots and the xls import table (as pdf) might be of some help.

1
2
3
4
Only local images are allowed.

GuyPaddock’s picture

@papalapapp: With that set-up, don't you end up with 1-1 product display to product SKU matchings? In the sample you provided of the 3 MacBooks, how many products and how many product displays do you end up with?

GuyPaddock’s picture

Okay, just checked and it looks like this is working as expected as long as the following is true:

  1. Your product display has a Product reference type field that has Number of values set to Unlimited (or, at least, isn't 1). (This is very important and easy to overlook, which is why I mention it first.)
  2. Commerce Feeds is installed and enabled.
  3. You are using the Node processor, configured to match the bundle of your product display content type.
  4. You have the Update existing nodes setting on the Node processor set to Update existing nodes. (There is magical code in Commerce Feeds that looks for this setting. If it isn't set, then it will not handle mapping multiple SKUs on one display.)
  5. You are mapping to the Product: SKU or Product: Product ID fields. (These are the only fields that have the special behavior of supporting multiple SKUs on the same display.)
  6. You have at least one field mapping with Used as unique set.

Now, according to How to configure unique fields in Drupal feeds importer?, that last requirement can be satisfied by creating a unique value validation for any field you want to use as a unique key for the same display. I'm currently trying to figure out how to do that on my end, but I can say that using Title as unique did work for me so far as long as everything above was satisfied.

GuyPaddock’s picture

Okay, two additional pieces that will help with satisfying requirement 6 in comment #19 with the Field Validation module:

  1. You need the 7.x-2.x-dev release of Field Validation. (Integration between Field Validation and Feeds was fixed in #1705386: Feeds integration (Field validation) and committed on Oct 11 2014 in commit 63e1e83.)
  2. You need the 7.x-2.x-dev release of Feeds. (Support for the callbacks needed by Field Validation was added on Wed Aug 27 2014 in commit f22a0f7.)
BrianLP’s picture

I haven't been working on that project for a while so I currently don't have an answer form the top of my head. However, rfay has a link to three screencasts on this in comment #8. I recall that they were very useful for me.

respown’s picture

Version: 7.x-1.3 » 7.x-1.4

Ok. So there's how I sorted that.

CSV structure like:
ProdDisplay1, product1, field1
ProdDisplay1, product2, field2
ProdDisplay1, product3, field3
ProdDisplay2, product4, field4
Is completely fine and easy to use to import in feeds.

You don't even need field with specified Display Name as long as you can extract that by REGEX replace (in Field Tamper module).

My CSV looked like:
Title; SKU; Pack size

But the title did not match with display name and was a name of variation:
"New book about living cars - 1"; SKUAA1; "Pack size 1"
"New book about living cars - 3"; SKUAA2; "Pack size 3"
"New book about living cars - 5"; SKUAA3; "Pack size 5"

Instead of playing with spreadsheets and soft like EXCEL/Gdocs in product importer I have imported typically:
Title -> "Product Title"
SKU -> SKU (unique)

But in Product Reference Importer I used Tamper to replace my "- [number]" by REGEX:
/((\s+-\s(\d*))|(-(\d*)))+/

That way we have Display Name to import:
Title -> Title (unique);
SKU -> Product variations (SKU)

And the most important in Product Reference importer settings: Node processor, there has to be "Update existing nodes" option ticked.

That way we (using the same CSV):

  • Import products with Product Importer
  • Import product reference node: where if there is already node with the same unique field (our title), sku reference will be added.

And all that in Fields and Tamper settings.

millionleaves’s picture

#22 is the approach I've been using for a while:

  • Create a CSV with a column for the node title and another for the product title (so the shopping cart and order confirmation email specify which product has been purchased).
  • Import the products
  • Import the product displays (using the same CSV file) and map them to the product reference field.

The only difference in my approach is that I would edit my spreadsheet in Excel prior to import and create additional columns with formulas to generate the product display node title, rather than using Feeds Tamper. This allows me to visualise my data prior to import and pick up any potential issues that would cause problems.

For example, the Excel formula to achieve what #22 did with a REGEX is:

=LEFT(A2,FIND(" - ",A2)-1)

This assumes the Title value above is in A2. There are more examples of such formulas here (and in the comments);

http://fiveminutelessons.com/learn-microsoft-excel/extract-text-cell-excel

I figure this might help people who would otherwise struggle with writing REGEX.

aumcara’s picture

Hi there,
I am actualy testing importation of some products into a C.Kickstatt 2 with Feeds and feeds tamper etc etc.

all these products are translated with entity translation etc...

I am asking myself if I can import all languages in a single import csv file and process everything in a single operation (gosh that would be great) or if I need to have several import .csv files per languages ... witch will be quiet a boring thing to prepare ... I guess some of you will agree witbh me :-)

I did actualy manage to import French products as product variations and did manage to import node related to those multiple variations with feeds tamper ... and this with the help of the video of Randy Fay avaialble at : https://vimeo.com/25668519

But it would help me quiet a lot for the import of all the others products I need to import after my tests ...

Oh, I almost forgot :

- is it possible while importing to only have "ONE IMAGE" for some of my same products variations
and
- would it be possible to have differents "image file name per language" for those different language variations :

exemple : for the english product : MUG we would have :

mug.jpg for EN
gobelet.jpg for FR
pot.jpg for NL

would it be possible to explain how to achierve this also ...

Many tbanks for your replies and or recommendations.