From 2afb015a6aa34786be19b59ed2ae48a6e9961983 Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 11 Jun 2020 17:55:02 +0900 Subject: [PATCH] fixed mass update attribute column for all attr types --- packages/Webkul/Product/src/Listeners/ProductFlat.php | 2 +- .../Product/src/Repositories/ProductFlatRepository.php | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/Webkul/Product/src/Listeners/ProductFlat.php b/packages/Webkul/Product/src/Listeners/ProductFlat.php index 340255db0..090763211 100644 --- a/packages/Webkul/Product/src/Listeners/ProductFlat.php +++ b/packages/Webkul/Product/src/Listeners/ProductFlat.php @@ -137,7 +137,7 @@ class ProductFlat } }); - $this->productFlatRepository->updateAttributeColumn( $attribute ); + $this->productFlatRepository->updateAttributeColumn( $attribute , $this ); } } diff --git a/packages/Webkul/Product/src/Repositories/ProductFlatRepository.php b/packages/Webkul/Product/src/Repositories/ProductFlatRepository.php index d49a7efea..2f33f4a82 100644 --- a/packages/Webkul/Product/src/Repositories/ProductFlatRepository.php +++ b/packages/Webkul/Product/src/Repositories/ProductFlatRepository.php @@ -92,13 +92,16 @@ class ProductFlatRepository extends Repository * update product_flat custom column * * @param \Webkul\Attribute\Models\Attribute $attribute + * @param \Webkul\Product\Listeners\ProductFlat $listener */ - public function updateAttributeColumn( \Webkul\Attribute\Models\Attribute $attribute ) { + public function updateAttributeColumn( + \Webkul\Attribute\Models\Attribute $attribute , + \Webkul\Product\Listeners\ProductFlat $listener ) { return $this->model ->leftJoin('product_attribute_values as v', function($join) use ($attribute) { $join->on('product_flat.id', '=', 'v.product_id') ->on('v.attribute_id', '=', \DB::raw($attribute->id)); - })->update(['product_flat.'.$attribute->code => \DB::raw($attribute->type .'_value')]); + })->update(['product_flat.'.$attribute->code => \DB::raw($listener->attributeTypeFields[$attribute->type] .'_value')]); } } \ No newline at end of file