Skip to content

Commit

Permalink
Added current product emabled status to import controller …….. n+1 pr…
Browse files Browse the repository at this point in the history
…oblem created but no way around it
  • Loading branch information
joshangell committed May 20, 2021
1 parent ceb2652 commit 2783f7e
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/controllers/ProductsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
];
}
Expand Down

0 comments on commit 2783f7e

Please sign in to comment.