Skip to content

Commit

Permalink
Fix product sync error when some products are soft deleted
Browse files Browse the repository at this point in the history
Fixes #3 again
  • Loading branch information
Tam committed Jul 11, 2019
1 parent b24b35d commit ad92860
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.1.3 - 2019-07-11
### Fixed
- Fix product sync error when some products are soft deleted (Fixes #3 again)

## 1.1.2 - 2019-06-28
### Fixed
- Fix casting issue on some properties
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "ether/mailchimp-commerce",
"description": "Mailchimp integration with Craft Commerce",
"version": "1.1.2",
"version": "1.1.3",
"type": "craft-plugin",
"keywords": [
"mailchimp",
Expand Down
16 changes: 10 additions & 6 deletions src/services/ChimpService.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,13 @@ public function getProducts ()
},
'getProductIds' => function ($typeId) {
$productIdsQuery = (new Query())
->select('id')
->from('{{%commerce_products}}');
->select('[[p.id]]')
->leftJoin('{{%elements}} e', '[[e.id]] = [[p.id]]')
->where(['e.dateDeleted' => null])
->from('{{%commerce_products}} p');

if ($typeId)
$productIdsQuery->where(['typeId' => $typeId]);
$productIdsQuery->andWhere(['p.typeId' => $typeId]);

return $productIdsQuery->column();
},
Expand Down Expand Up @@ -112,11 +114,13 @@ public function getProducts ()
},
'getProductIds' => function ($typeId) {
$productIdsQuery = (new Query())
->select('id')
->from('{{%events_events}}');
->select('[[p.id]]')
->leftJoin('{{%elements}} e', '[[e.id]] = [[p.id]]')
->where(['e.dateDeleted' => null])
->from('{{%events_events}} p');

if ($typeId)
$productIdsQuery->where(['typeId' => $typeId]);
$productIdsQuery->where(['p.typeId' => $typeId]);

return $productIdsQuery->column();
},
Expand Down

0 comments on commit ad92860

Please sign in to comment.