Skip to content

Commit 114e68f

Browse files
committed
Fix database error when creating new products
1 parent 45cf8bb commit 114e68f

3 files changed

Lines changed: 13 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 1.1.1 - 2019-07-10
2+
### Fixed
3+
- Fixed database error when creating new products
4+
15
## 1.1.0 - 2019-06-17
26
### Added
37
- Added "Extended" product query (requires fresh install)

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "ether/purchase-patterns",
33
"description": "Easily keep track of and show products customers bought together. Plus, sorting by individual and order sales.",
4-
"version": "1.1.0",
4+
"version": "1.1.1",
55
"type": "craft-plugin",
66
"license": "proprietary",
77
"minimum-stability": "dev",

src/PurchasePatterns.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Craft;
1212
use craft\base\Plugin;
1313
use craft\commerce\elements\Order;
14+
use craft\commerce\elements\Product;
1415
use craft\events\RegisterComponentTypesEvent;
1516
use craft\services\Dashboard;
1617
use craft\web\twig\variables\CraftVariable;
@@ -153,9 +154,13 @@ public function onRegisterWidgets (RegisterComponentTypesEvent $event)
153154
*/
154155
public function hookProductEditDetails (array &$context)
155156
{
156-
$purchasedWith = $this->getService()->getBoughtTogetherMeta(
157-
$context['product']
158-
);
157+
/** @var Product $product */
158+
$product = $context['product'];
159+
160+
if (!$product->id)
161+
return null;
162+
163+
$purchasedWith = $this->getService()->getBoughtTogetherMeta($product);
159164

160165
return Craft::$app->getView()->renderTemplate(
161166
'purchase-patterns/_product/edit',

0 commit comments

Comments
 (0)