Skip to content

Commit

Permalink
Make IsotopeProduct interface useable
Browse files Browse the repository at this point in the history
  • Loading branch information
aschempp committed Apr 26, 2016
1 parent f25fa43 commit 25aa89b
Show file tree
Hide file tree
Showing 13 changed files with 379 additions and 270 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

namespace Isotope\Interfaces;

use Isotope\Model\ProductType;


/**
* IsotopeProduct is the interface for a product object
Expand Down Expand Up @@ -39,6 +41,27 @@ public function getProductId();
*/
public function getFormId();

/**
* Returns the product type for this product, or null if not applicable or not found.
*
* @return ProductType|null
*/
public function getType();

/**
* Returns the product name, necessary to store as fallback in the product collection.
*
* @return string
*/
public function getName();

/**
* Returns the product SKU, necessary to store as fallback in the product collection.
*
* @return string
*/
public function getSku();

/**
* Returns true if the product is available in the frontend
*
Expand Down Expand Up @@ -83,6 +106,13 @@ public function isExemptFromShipping();
*/
public function hasVariants();

/**
* Returns an array of variant IDs
*
* @return array
*/
public function getVariantIds();

/**
* Returns true if this product is a variant
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,6 @@ public function generate(IsotopeProduct $objProduct, array $arrOptions = array()
return '';
}

return $objPrice->generate($objProduct->getRelated('type')->showPriceTiers());
return $objPrice->generate($objProduct->getType()->showPriceTiers());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ public static function findByProductAndAttribute(IsotopeProduct $objProduct, Iso
"$t.published='1'"
),
array(
$objProduct->id,
$objProduct->getId(),
$objAttribute->getFieldName()
),
['order' => "$t.sorting"]
Expand Down
2 changes: 1 addition & 1 deletion system/modules/isotope/library/Isotope/Model/Gallery.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public static function createForProductAttribute(IsotopeProduct $objProduct, $st
deserialize($objProduct->$strAttribute, true),
deserialize($objProduct->{$strAttribute . '_fallback'}, true)
));
$objGallery->product_id = ($objProduct->pid ? $objProduct->pid : $objProduct->id);
$objGallery->product_id = $objProduct->getProductId();
$objGallery->href = $objProduct->generateUrl($arrConfig['jumpTo']);

return $objGallery;
Expand Down
3 changes: 2 additions & 1 deletion system/modules/isotope/library/Isotope/Model/Payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,8 @@ public function isAvailable()

foreach ($arrItems as $objItem) {
if ($objItem->hasProduct()) {
$arrItemTypes[] = $objItem->getProduct()->type;
$productType = $objItem->getProduct()->getType();
$arrItemTypes[] = null === $productType ? 0 : $productType->id;

} elseif ('onlyAvailable' === $this->product_types_condition) {
// If one product in cart is not of given type, shipping method is not available
Expand Down
12 changes: 10 additions & 2 deletions system/modules/isotope/library/Isotope/Model/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

use Isotope\Interfaces\IsotopeProduct;
use Isotope\Model\Attribute;
use Isotope\Model\Product\Standard;
use Isotope\RequestCache\Filter;


Expand Down Expand Up @@ -50,7 +49,7 @@
* @property string $start
* @property string $stop
*/
abstract class Product extends TypeAgent
abstract class Product extends TypeAgent implements IsotopeProduct
{

/**
Expand All @@ -77,6 +76,15 @@ abstract class Product extends TypeAgent
*/
protected static $arrActive = array();

/**
* Get categories (pages) assigned to this product
*
* @param bool $blnPublished Only return published categories (pages)
*
* @return array
*/
abstract public function getCategories($blnPublished = false);

/**
* Get product that is currently active (needed e.g. for insert tag replacement)
*
Expand Down

0 comments on commit 25aa89b

Please sign in to comment.