diff --git a/CHANGELOG.md b/CHANGELOG.md index 8455f2a..f00400d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,12 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p ## Unreleased +## 2.5.9 - 2021-05-20 + +### Changed +- Added the enabled status of the current product to the Feed Me API if the product already exists. + + ## 2.5.8 - 2021-05-20 ### Fixed diff --git a/src/controllers/ProductsController.php b/src/controllers/ProductsController.php index 1101f9f..19caeb0 100644 --- a/src/controllers/ProductsController.php +++ b/src/controllers/ProductsController.php @@ -13,6 +13,7 @@ use angellco\vend\models\Settings; use angellco\vend\Vend; use Craft; +use craft\commerce\elements\Product; use craft\db\Paginator; use craft\elements\Entry; use craft\helpers\DateTimeHelper; @@ -241,9 +242,16 @@ public function actionImport(): Response } } + // Get the current product if there is one + $productQuery = Product::find(); + $productQuery->status = null; + $productQuery->vendProductId = $rawProduct->vendProductId; + $commerceProduct = $productQuery->one(); + $products[] = [ 'id' => $rawProduct->vendProductId, 'name' => $rawProduct->title, + 'enabled' => $commerceProduct ? $commerceProduct->enabled : false, 'variants' => $variants ]; }