← All changes
|
includes/Admin/Product/Data/Services/AttributeService.php
+5
-17
1.10.27
→
1.1.26
View file →
| @@ -24,31 +24,19 @@ | ||
| 24 | 24 | $isEnabled = syncBasalamSettings()->getSettings(SettingsConfig::PRODUCT_ATTRIBUTE_SUFFIX_ENABLED); |
| 25 | 25 | |
| 26 | 26 | if ($isEnabled !== 'yes') return null; |
| 27 | 27 | |
| 28 | - $configuredNames = (string) syncBasalamSettings()->getSettings(SettingsConfig::PRODUCT_ATTRIBUTE_SUFFIX_PRIORITY); | |
| 29 | - $attributeNames = array_unique(array_filter( | |
| 30 | - array_map('trim', preg_split('/[,،]/u', $configuredNames)), | |
| 31 | - static function ($name) { return $name !== ''; } | |
| 32 | - )); | |
| 28 | + $attributeName = trim(syncBasalamSettings()->getSettings(SettingsConfig::PRODUCT_ATTRIBUTE_SUFFIX_PRIORITY)); | |
| 33 | 29 | |
| 34 | - if (empty($attributeNames)) return null; | |
| 30 | + if (empty($attributeName)) return null; | |
| 35 | 31 | |
| 36 | 32 | $wooAttributes = $this->getWooCommerceAttributes($product); |
| 37 | - $suffixValues = []; | |
| 38 | 33 | |
| 39 | - // Follow the configured order, regardless of the product's attribute order. | |
| 40 | - foreach ($attributeNames as $attributeName) { | |
| 41 | - foreach ($wooAttributes as $attribute) { | |
| 42 | - $value = trim($attribute['value']); | |
| 43 | - if (trim($attribute['title']) === $attributeName && $value !== '') { | |
| 44 | - $suffixValues[] = $value; | |
| 45 | - break; | |
| 46 | - } | |
| 47 | - } | |
| 34 | + foreach ($wooAttributes as $attribute) { | |
| 35 | + if (trim($attribute['title']) === $attributeName && !empty($attribute['value'])) return $attribute['value']; | |
| 48 | 36 | } |
| 49 | 37 | |
| 50 | - return empty($suffixValues) ? null : implode(', ', $suffixValues); | |
| 38 | + return null; | |
| 51 | 39 | } |
| 52 | 40 | |
| 53 | 41 | public function generateDescription($product): string |
| 54 | 42 | { |