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
Import Price for Commerce 5 does not work #1439
Comments
Same thing for Inventory/stock, this structure changed in Commerce 5. Also, the setting Promotable does not seem to work as well. |
Quick hotfix as we wait for the official fix. \yii\base\Event::on(\craft\feedme\services\Process::class, \craft\feedme\services\Process::EVENT_STEP_BEFORE_ELEMENT_SAVE, function(\craft\feedme\events\FeedProcessEvent $event) {
$feedData = $event->feedData;
/** @var craft\commerce\elements\Product $element */
$element = $event->element;
$elementType = get_class($element);
if ($elementType === 'craft\commerce\elements\Product') {
$defaultVariant = $element->getDefaultVariant();
if (!$defaultVariant) {
return;
}
$price = $feedData['price'] ?? null;
if ($price) {
$defaultVariant->setBasePrice((float)$price);
}
}
}); |
@MatoTominac Thanks for the hotfix, although it does not work for me. It works neither with csv imported values nor with the fallback value. Were you able to test your module? |
@sandrodunkel you probably need to update the line $price = $feedData[7] ?? null; // 7 is the index of pricing column in csv |
@MatoTominac Thanks for the hint! I got it working—I made an upper/lowercase error… :S I adjusted the code to import the price for each variant and not just the default one: if ($elementType === 'craft\commerce\elements\Product') {
$variants = $element->getVariants();
foreach ($variants as $variant) {
$price = $feedData["Price"] ?? null;
if ($price) {
$variant->setBasePrice((float)$price);
}
}
} I'm going to try to do something similar with the stock for now. |
We have a Commerce 5 compatibility PR #1448, to test it out change your "require": {
"craftcms/feed-me": "dev-feature/commerce-5-support as 6.0.1"
"...": "..."
} Then run |
Description
I'm trying to import a lot of products using a local CSV file. The mapping and import works for all selected properties except the variant price, which is set to 0. Maybe that has something to do with the change in the way Price and Promotional Price are being handled in Commerce 5.
When checking the Debug-mode provided by feed-me, the price is being mapped correctly. I also tried not mapping the price to a CSV column but rather using the Default Value option, but this didn't work either. Price is still 0.
Steps to reproduce
Additional info
The text was updated successfully, but these errors were encountered: