continue;
}
$options = Json::decodeRecursive($specEntity->options, Json::TYPE_ARRAY);
- if (!isset($options[$val])) {
+ $specValue = $this->_optionValue($options, $val);
+ if (null === $specValue) {
continue;
}
- $option = $options[$val];
-
- $locale = App::getLocale();
- if (!isset($option[$locale]) || !$option[$locale]) {
- $specValue = $option['fr'] ?? '';
- } else {
- $specValue = $option[$locale];
+ } else if ($specEntity->type === 'mlist') {
+ $options = Json::decodeRecursive($specEntity->options, Json::TYPE_ARRAY);
+ $thisSpecs = [];
+ foreach ($val as $v) {
+ $r = $this->_optionValue($options, $v);
+ if ($r === null) {
+ continue;
+ }
+ $thisSpecs[] = $r;
}
+ $specValue = implode(', ', $thisSpecs);
}
$res[$specEntity->label] = $specValue;
}
}
+ protected function _optionValue($options, $val)
+ {
+ if (!isset($options[$val])) {
+ return null;
+ }
+ $option = $options[$val];
+
+ $locale = App::getLocale();
+ if (!isset($option[$locale]) || !$option[$locale]) {
+ $specValue = $option['fr'] ?? '';
+ } else {
+ $specValue = $option[$locale];
+ }
+ return $specValue;
+ }
+
/**
* Custom accessor to return URL to product detail
* page by accessing $product->URL...