craftcms / feed-me

Craft CMS plugin for importing entry data from XML, RSS or ATOM feeds—routine task or on-demand.
Other
287 stars 140 forks source link

Importing commerce product - treating price as NULL even though it shows it as mapped correctly #1034

Open paulgoodfield opened 3 years ago

paulgoodfield commented 3 years ago

Description

When creating a feed to import a Commerce Product, after mapping Price to field in CSV like so...

Screenshot 2021-09-01 at 22 43 55

...the actual import fails when run and shows following error message in feed logs:

Integrity constraint violation: 1048 Column 'price' cannot be null

Screenshot 2021-09-01 at 22 55 46

In the logs line where it says Data ready to import there's no mention of price even though it was mapped.

Steps to reproduce

  1. Create feed to import new Commerce Products
  2. Map Price field to relevant field in CSV file you're importing
  3. Run feed and see failed tasks in logs as detailed above

Additional info

Abandoned Cart for Craft Commerce 1.6.3 AsyncQueue 2.3.0 Colour Swatches 1.4.2 Cookies 1.1.15 CP Field Inspect 1.2.5 Craft Commerce 3.4.2 Environment Label 3.2.0 Freeform 3.11.10 Preparse Field 1.2.5 Redactor 2.8.8 Retour 3.1.61 Sage Pay for Craft Commerce 3.0.0 Section + Product Type 1.0.5 SEOmatic 3.4.6 Single Cat 1.2.1 Sprig 1.8.1 Super Table 2.6.8 Tags 1.0.7

paulgoodfield commented 3 years ago

After further testing we've determined that this is actually an issue pertaining to Product Types that have an Automatic SKU Format set.

We've set a Product Type to use the Automatic SKU Format of {{ object.product.slug }}-{{ seq(object.product.slug) }} as suggested in the Commerce docs here: https://craftcms.com/docs/commerce/3.x/products-variants.html#automatic-sku-format

In the feed settings, if we leave the SKU mapping as Don't import then we get the above Integrity constraint violation: 1048 Column 'price' cannot be null error. The feed logs show the data it's trying to import as:

{"title":"Buff Wicker 4 Bottle Basket","slug":"buff-wicker-4-bottle-basket","taxCategoryId":"1","shippingCategoryId":"1","productCode":"BH010","originalId":"1"}

If we set the SKU mapping to some value in the CSV file rather than as Don't import then it processes fine without error. The logs then show this as the data it's importing:

{"title":"Buff Wicker 4 Bottle Basket","slug":"buff-wicker-4-bottle-basket","taxCategoryId":"1","shippingCategoryId":"1","productCode":"BH010","originalId":"1","variants":[{"title":"Buff Wicker 4 Bottle Basket","sku":"BH010","height":"18","width":"26","length":null,"stock":"0","price":"12.63"}]}

Could this be an issue with the specific automatic SKU format we're using or just automatic SKUs in general?

andrewhawkes commented 2 years ago

I'm getting this same issue whilst trying to update a single field on products:

Integrity constraint violation: 1048 Column 'price' cannot be null The SQL being executed was: INSERT INTO commerce_variants

Is there a way this check for the price can be skipped?

nilsenpaul commented 1 year ago

Any news on this? We get this same error (on some products), causing the import to stop and the rest of the products to not be updated. We don't update the price (but the stock fields), and the feed is configured to only update products (not create 'em).

hassanmah commented 7 months ago

@paulgoodfield did you fix a fix for this? I've still seeing the issue in the latest version

paulgoodfield commented 7 months ago

@hassanmah I don't recall I'm afraid. The issue was originally noticed over 2 years ago.