feed-me
feed-me copied to clipboard
Importing commerce product - treating price as NULL even though it shows it as mapped correctly
Description
When creating a feed to import a Commerce Product, after mapping Price to field in CSV like so...

...the actual import fails when run and shows following error message in feed logs:
Integrity constraint violation: 1048 Column 'price' cannot be null

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
- Create feed to import new Commerce Products
- Map Price field to relevant field in CSV file you're importing
- Run feed and see failed tasks in logs as detailed above
Additional info
- Craft CMS version: Pro 3.7.11
- Feed Me version: 4.4.0
- PHP version: 7.4.18
- Database driver & version: MySQL 8.0.25
- Other plugins & versions:
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
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?
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?
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).
@paulgoodfield did you fix a fix for this? I've still seeing the issue in the latest version
@hassanmah I don't recall I'm afraid. The issue was originally noticed over 2 years ago.