From e5f1b33f48cbce46885d55746cd0e8f8077ca3ed Mon Sep 17 00:00:00 2001 From: Poghos Date: Mon, 26 Apr 2021 13:27:30 +0400 Subject: [PATCH] Improved ProductFlat listener to make fillable attribute codes overridable --- .../Webkul/Product/src/Listeners/ProductFlat.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/packages/Webkul/Product/src/Listeners/ProductFlat.php b/packages/Webkul/Product/src/Listeners/ProductFlat.php index 090763211..aa0146171 100644 --- a/packages/Webkul/Product/src/Listeners/ProductFlat.php +++ b/packages/Webkul/Product/src/Listeners/ProductFlat.php @@ -48,6 +48,19 @@ class ProductFlat */ protected $attribute; + /** + * Attribute codes that can be fill during flat creation. + * + * @var string[] + */ + protected $fillableAttributeCodes = [ + 'sku', + 'name', + 'price', + 'weight', + 'status' + ]; + /** * @var array */ @@ -212,7 +225,7 @@ class ProductFlat } foreach ($familyAttributes[$product->attribute_family->id] as $attribute) { - if ($parentProduct && ! in_array($attribute->code, array_merge($superAttributes[$parentProduct->id], ['sku', 'name', 'price', 'weight', 'status']))) { + if ($parentProduct && ! in_array($attribute->code, array_merge($superAttributes[$parentProduct->id], $this->fillableAttributeCodes))) { continue; }