Skip to content

Commit

Permalink
Fix database error when creating new products
Browse files Browse the repository at this point in the history
  • Loading branch information
Tam committed Jul 10, 2019
1 parent 45cf8bb commit 114e68f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 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.1 - 2019-07-10
### Fixed
- Fixed database error when creating new products

## 1.1.0 - 2019-06-17
### Added
- Added "Extended" product query (requires fresh install)
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/purchase-patterns",
"description": "Easily keep track of and show products customers bought together. Plus, sorting by individual and order sales.",
"version": "1.1.0",
"version": "1.1.1",
"type": "craft-plugin",
"license": "proprietary",
"minimum-stability": "dev",
Expand Down
11 changes: 8 additions & 3 deletions src/PurchasePatterns.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use Craft;
use craft\base\Plugin;
use craft\commerce\elements\Order;
use craft\commerce\elements\Product;
use craft\events\RegisterComponentTypesEvent;
use craft\services\Dashboard;
use craft\web\twig\variables\CraftVariable;
Expand Down Expand Up @@ -153,9 +154,13 @@ public function onRegisterWidgets (RegisterComponentTypesEvent $event)
*/
public function hookProductEditDetails (array &$context)
{
$purchasedWith = $this->getService()->getBoughtTogetherMeta(
$context['product']
);
/** @var Product $product */
$product = $context['product'];

if (!$product->id)
return null;

$purchasedWith = $this->getService()->getBoughtTogetherMeta($product);

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

0 comments on commit 114e68f

Please sign in to comment.