diff --git a/src/Model/Product/ProductVariant.php b/src/Model/Product/ProductVariant.php index 4e81eb35b1..522e48c27d 100644 --- a/src/Model/Product/ProductVariant.php +++ b/src/Model/Product/ProductVariant.php @@ -29,6 +29,8 @@ * @method ProductVariant setAvailability(LocalizedString $availability = null) * @method Price getPrice() * @method ProductVariant setPrice(Price $price = null) + * @method bool getIsMatchingVariant() + * @method ProductVariant setIsMatchingVariant(bool $isMatchingVariant = null) */ class ProductVariant extends JsonObject { @@ -42,6 +44,7 @@ public function fieldDefinitions() 'attributes' => [static::TYPE => '\Commercetools\Core\Model\Common\AttributeCollection'], 'images' => [static::TYPE => '\Commercetools\Core\Model\Common\ImageCollection'], 'availability' => [static::TYPE => '\Commercetools\Core\Model\Common\LocalizedString'], + 'isMatchingVariant' => [static::TYPE => 'bool'] ]; } } diff --git a/src/Model/Product/ProductVariantCollection.php b/src/Model/Product/ProductVariantCollection.php index 251bdae6b5..f0a2dc6def 100644 --- a/src/Model/Product/ProductVariantCollection.php +++ b/src/Model/Product/ProductVariantCollection.php @@ -17,6 +17,7 @@ class ProductVariantCollection extends Collection { const ID = 'id'; const SKU = 'sku'; + const MATCHING = 'isMatchingVariant'; protected $type = '\Commercetools\Core\Model\Product\ProductVariant'; protected function indexRow($offset, $row) @@ -24,12 +25,15 @@ protected function indexRow($offset, $row) if ($row instanceof ProductVariant) { $id = $row->getId(); $sku = $row->getSku(); + $matching = $row->getIsMatchingVariant(); } else { $id = isset($row[static::ID])? $row[static::ID] : null; $sku = isset($row[static::SKU])? $row[static::SKU] : null; + $matching = isset($row[static::MATCHING])? $row[static::MATCHING] : false; } $this->addToIndex(static::ID, $offset, $id); $this->addToIndex(static::SKU, $offset, $sku); + $this->addToIndex(static::MATCHING, $offset, $matching); } /** @@ -49,4 +53,9 @@ public function getBySku($id) { return $this->getBy(static::SKU, $id); } + + public function getMatchingVariant() + { + return $this->getBy(static::MATCHING, true); + } }