Skip to content

Commit

Permalink
convert products as dataobjects
Browse files Browse the repository at this point in the history
  • Loading branch information
KavindaHarshana committed Oct 21, 2024
1 parent b543822 commit 7e75df9
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/Cart/ShoppingCart.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use SilverStripe\Core\Config\Configurable;
use SilverStripe\Core\Injector\Injectable;
use SilverStripe\Omnipay\Model\Payment;
use SilverStripe\ORM\DataObject;
use SilverStripe\Security\Member;
use SilverStripe\Security\Security;

Expand Down Expand Up @@ -495,7 +496,7 @@ public function get(Buyable $buyable, $customFilter = [])
*/
public function getCorrectBuyable(Buyable $buyable)
{
if ($buyable instanceof Product
if ($buyable instanceof DataObject
&& $buyable->hasExtension(ProductVariationsExtension::class)
&& $buyable->Variations()->count() > 0
) {
Expand Down
3 changes: 2 additions & 1 deletion src/Model/Product/OrderItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace SilverShop\Model\Product;

use SilverShop\Page\Product;
use SilverStripe\ORM\DataObject;
use SilverStripe\Versioned\Versioned;

/**
Expand All @@ -19,7 +20,7 @@ class OrderItem extends \SilverShop\Model\OrderItem
];

private static $has_one = [
'Product' => Product::class,
'Product' => DataObject::class,
];

private static $table_name = 'SilverShop_Product_OrderItem';
Expand Down
2 changes: 1 addition & 1 deletion src/Model/Variation/AttributeType.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class AttributeType extends DataObject
];

private static $belongs_many_many = [
'Product' => Product::class,
'Product' => DataObject::class,
];

private static $summary_fields = [
Expand Down
2 changes: 1 addition & 1 deletion src/Model/Variation/Variation.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class Variation extends DataObject implements Buyable
];

private static $has_one = [
'Product' => Product::class,
'Product' => DataObject::class,
'Image' => Image::class
];

Expand Down
2 changes: 1 addition & 1 deletion src/Page/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ public function getCategories()
* @return boolean
*/
public function canPurchase($member = null, $quantity = 1)
{
{die('aaaaaa');
$global = self::config()->global_allow_purchase;

if (!$global || !$this->AllowPurchase) {
Expand Down
3 changes: 2 additions & 1 deletion src/Page/ProductCategory.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use SilverShop\Extension\ProductVariationsExtension;
use SilverStripe\i18n\i18nEntityProvider;
use SilverStripe\ORM\DataList;
use SilverStripe\ORM\DataObject;

/**
* Product Category provides a way to hierartically categorise products.
Expand All @@ -17,7 +18,7 @@
class ProductCategory extends Page implements i18nEntityProvider
{
private static $belongs_many_many = [
'Products' => Product::class,
'Products' => DataObject::class,
];

private static $singular_name = 'Category';
Expand Down

0 comments on commit 7e75df9

Please sign in to comment.