@@ -101,6 +101,7 @@ public function execute(int $storeId, array $extra = [], SearchCriteriaInterface
101
101
$ ean = $ this ->configRepository ->getEan ($ storeId );
102
102
$ name = $ this ->configRepository ->getName ($ storeId );
103
103
$ sku = $ this ->configRepository ->getSku ($ storeId );
104
+ $ brand = $ this ->configRepository ->getBrand ($ storeId );
104
105
105
106
$ data = [];
106
107
$ collection = $ this ->getCollection ($ storeId , $ extra , $ searchCriteria );
@@ -112,15 +113,16 @@ public function execute(int $storeId, array $extra = [], SearchCriteriaInterface
112
113
}
113
114
$ data [] = [
114
115
"id " => $ product ->getId (),
115
- "title " => ( $ name ) ? $ product -> getData ( $ name ) : '' ,
116
+ "title " => $ this -> getAttributeValue ( $ product , $ name ),
116
117
"article_code " => $ product ->getSku (),
117
- "ean " => ( $ ean ) ? $ product -> getData ( $ ean ) : '' ,
118
+ "ean " => $ this -> getAttributeValue ( $ product , $ ean ),
118
119
"main_image " => $ this ->getMainImage ($ product ),
119
120
"price_cost " => $ product ->getCost (),
120
121
"price_excl " => $ product ->getPrice (),
121
122
"price_incl " => $ product ->getPrice (),
122
123
"unit_price " => $ product ->getPrice (),
123
- "sku " => ($ sku ) ? $ product ->getData ($ sku ) : '' ,
124
+ "sku " => $ this ->getAttributeValue ($ product , $ sku ),
125
+ "brand " => $ this ->getAttributeValue ($ product , $ brand ),
124
126
"stock_level " => $ this ->getStockLevel ($ product , $ stockData , $ websiteId ),
125
127
"product_id " => $ productIds [$ product ->getId ()],
126
128
"created_at " => $ product ->getCreatedAt (),
@@ -130,6 +132,24 @@ public function execute(int $storeId, array $extra = [], SearchCriteriaInterface
130
132
return $ data ;
131
133
}
132
134
135
+ /**
136
+ * @param $product
137
+ * @param $attribute
138
+ * @return mixed|string
139
+ */
140
+ private function getAttributeValue ($ product , $ attribute )
141
+ {
142
+ $ value = '' ;
143
+ if ($ attribute ) {
144
+ if ($ dropdownValue = $ product ->getAttributeText ($ attribute )) {
145
+ $ value = $ dropdownValue ;
146
+ } else {
147
+ $ value = $ product ->getData ($ attribute );
148
+ }
149
+ }
150
+ return $ value ;
151
+ }
152
+
133
153
/**
134
154
* @param int|null $entityId
135
155
*
0 commit comments