From 10e92dada33a5782474d3d7d2c67c74d5eac1ccd Mon Sep 17 00:00:00 2001 From: jitendra Date: Fri, 26 Apr 2019 12:43:42 +0530 Subject: [PATCH] Now variant's super attributes values are saving in product_flat table --- packages/Webkul/Product/src/Listeners/ProductFlat.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/Webkul/Product/src/Listeners/ProductFlat.php b/packages/Webkul/Product/src/Listeners/ProductFlat.php index d72085359..bd36e6db8 100644 --- a/packages/Webkul/Product/src/Listeners/ProductFlat.php +++ b/packages/Webkul/Product/src/Listeners/ProductFlat.php @@ -158,9 +158,14 @@ class ProductFlat { static $familyAttributes = []; + static $superAttributes = []; + if (! array_key_exists($product->attribute_family->id, $familyAttributes)) $familyAttributes[$product->attribute_family->id] = $product->attribute_family->custom_attributes; + if ($parentProduct && ! array_key_exists($parentProduct->id, $superAttributes)) + $superAttributes[$parentProduct->id] = $parentProduct->super_attributes()->pluck('code')->toArray(); + foreach (core()->getAllChannels() as $channel) { foreach ($channel->locales as $locale) { $productFlat = $this->productFlatRepository->findOneWhere([ @@ -178,7 +183,7 @@ class ProductFlat } foreach ($familyAttributes[$product->attribute_family->id] as $attribute) { - if ($parentProduct && ! in_array($attribute->code, ['sku', 'name', 'price', 'weight', 'status'])) + if ($parentProduct && ! in_array($attribute->code, array_merge($superAttributes[$parentProduct->id], ['sku', 'name', 'price', 'weight', 'status']))) continue; if (in_array($attribute->code, ['short_description', 'tax_category_id', 'meta_title', 'meta_keywords', 'meta_description', 'width', 'height']))