Skip to content

Commit

Permalink
Fix setProductStyle method.
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexandre committed Mar 24, 2020
1 parent cac1663 commit df6cbdb
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/Object/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,15 @@ public function getProductStyle(): int
*/
public function setProductStyle(int $product_style): Product
{
if (!in_array($product_style, Provisionning::getInstance()->getProductStyles())) {
static $categories;
if (!is_array($categories) || !count($categories)) {
$categories = array_column(
Provisionning::getInstance()->getCategories(),
'code'
);
}

if (!in_array($product_style, $categories)) {
throw InvalidArgumentException::notSupportedProductStyle($product_style);
}

Expand Down

0 comments on commit df6cbdb

Please sign in to comment.