Skip to content
This repository has been archived by the owner on Oct 24, 2023. It is now read-only.

Commit

Permalink
feat(Product): add getAllVariants helper method to product data
Browse files Browse the repository at this point in the history
Closes #213
  • Loading branch information
Jens Schulze committed May 24, 2016
1 parent ee71818 commit 006e984
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Model/Product/ProductData.php
Expand Up @@ -81,4 +81,14 @@ public function getVariantBySku($sku)

return $this->getVariants()->getBySku($sku);
}

/**
* @return ProductVariantCollection
*/
public function getAllVariants()
{
$variants = $this->getRaw('variants', []);
array_unshift($variants, $this->getRaw('masterVariant'));
return ProductVariantCollection::fromArray($variants, $this->getContextCallback());
}
}

0 comments on commit 006e984

Please sign in to comment.