Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using Variant SKU as unique identifier to match against existing elements no longer works #1373

Open
jakelapan opened this issue Oct 26, 2023 · 4 comments
Labels

Comments

@jakelapan
Copy link

jakelapan commented Oct 26, 2023

Screen Shot 2023-10-26 at 11 40 18 AM

Description

Exception thrown: "Unable to match an existing element. Have you set a unique identifier for ["variant-sku"]? Make sure you are also mapping this in your feed and it has a value." I am using an existing feed and just upgraded from 5.1.4 and am now encountering this issue. I have double-checked that the variant-sku is mapped properly. This issue seemed to occur after updating to 5.2.0.

I also noticed that the map template has two section headings for "Variants Fields" (see screenshot), which seems off.

Steps to reproduce

  1. On the "Map" feed page, map the "Product Variant Fields" => "SKU" to sku node in json feed
  2. Select the "Variant SKU" option only in the "Set a unique identifier to match against existing elements" section
  3. Run the feed

Additional info

  • Craft version: Craft Pro 4.5.9
  • PHP version: 8.2.1
  • Database driver & version: MySQL 8.0.31
  • Plugins & versions: feed-me 5.2.0
@jakelapan jakelapan added the bug label Oct 26, 2023
@bjerenec
Copy link

I'm having the same (or similar) issue but I believe even on older versions (since 4.6.2?).
I'm updating a commerce site from craft v3 to the latest version.

It seems that when you select "Variant SKU" as unique identifier, parseAttribute function in base/Element.php tries to fetchSimpleValue but should in this case use fetchArrayValue instead?

In the ugly code below in parseAttribute I try to do that and it seems to help in my case but I would not trust it on production server so I'm waiting for official fix too.

// Set a default handler for non-specific attribute classes
if (!method_exists($this, $name)) {
  // ugly part to check exactly for variants/sku
  if ($fieldInfo['node'] === 'variants/sku') {
    return $this->fetchArrayValue($feedData, $fieldInfo);
  }
  else {
    return $this->fetchSimpleValue($feedData, $fieldInfo);
  }
}

@john-henry
Copy link

Also running into this issue

@i-just
Copy link
Contributor

i-just commented Sep 3, 2024

Hi, thanks for getting in touch! Can you please provide a bit more info about this? A screenshot of the mapping screen and a snippet of the feed (e.g. json file) would be particularly helpful. Also, are you importing a product that has one variant or multiple variants?

@bjerenec
Copy link

bjerenec commented Sep 8, 2024

I upgraded my dev install to latest craft v5/commerce v5/ feed me v6.3.0 and still have the same issue.
We have products defined with variants (some products have just one some have many variants).

Log shows errors for all products:
Screenshot 2024-09-08 at 21 01 56

Mapping:
Screenshot 2024-09-08 at 21 06 37

Screenshot 2024-09-08 at 21 04 06

JSON example:

{
      "sku": "95800",
      "title": "ASCAN KOMPLETNI PRO RIG",
      "enota": "SET",
      "splet_sifra": "25",
      "splet_naziv": "JADRA",
      "splet_skupina": "6",
      "splet_nivo": "3",
      "b2c": "",
      "tax": "22%",
      "enabled": 1,
      "variants": [
        {
          "sku": "95825",
          "enabled": 1,
          "title": "ASCAN PRO RIGG 2.5M2",
          "title2": "",
          "price": 236.885,
          "zaloga": 0,
          "enota": "SET",
          "barva": "",
          "velikost": "",
          "splet_sifra": "25",
          "splet_naziv": "JADRA",
          "splet_skupina": "6",
          "splet_nivo": "3",
          "b2c": "",
          "tax": "22%"
        },
        {
          "sku": "95845",
          "enabled": 1,
          "title": "ASCAN PRO RIGG 4,5",
          "title2": "",
          "price": 261.475,
          "zaloga": 0,
          "enota": "SET",
          "barva": "",
          "velikost": "",
          "splet_sifra": "25",
          "splet_naziv": "JADRA",
          "splet_skupina": "6",
          "splet_nivo": "3",
          "b2c": "",
          "tax": "22%"
        },
        {
          "sku": "95840",
          "enabled": 1,
          "title": "ASCAN PRO RIGG 4.0",
          "title2": "",
          "price": 245.082,
          "zaloga": 0,
          "enota": "SET",
          "barva": "",
          "velikost": "",
          "splet_sifra": "25",
          "splet_naziv": "JADRA",
          "splet_skupina": "6",
          "splet_nivo": "3",
          "b2c": "",
          "tax": "22%"
        },
        {
          "sku": "95950",
          "enabled": 1,
          "title": "ASCAN PRO RIGG 5,0",
          "title2": "",
          "price": 277.869,
          "zaloga": 0,
          "enota": "SET",
          "barva": "",
          "velikost": "",
          "splet_sifra": "25",
          "splet_naziv": "JADRA",
          "splet_skupina": "6",
          "splet_nivo": "3",
          "b2c": "",
          "tax": "22%"
        }
      ]
    },

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants