From df6cbdb550c2848ddaf81fb4cc1009e77954a925 Mon Sep 17 00:00:00 2001 From: Alexandre Date: Tue, 24 Mar 2020 10:59:59 +0700 Subject: [PATCH] Fix setProductStyle method. --- src/Object/Product.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Object/Product.php b/src/Object/Product.php index 0735c95..854c9c9 100644 --- a/src/Object/Product.php +++ b/src/Object/Product.php @@ -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); }