/** * @param JBCartVariant $variant * @return array */ public function getVariantData(JBCartVariant $variant) { $vars = $this->app->jbvars; $data = array(); if ($variant->isBasic()) { $elements = $variant->getCore(); } elseif ($variant->is(-1)) { $elements = $variant->all(); } else { $elements = $variant->getSimple(); } if (count($elements)) { /**@type JBCartElementPrice $element */ foreach ($elements as $paramId => $element) { $value = $element->getSearchData(); $value = $this->_helper->getValue($value); $string = (string) $value; $numeric = is_numeric($value) ? $vars->number($value) : null; $date = $this->_helper->isDate($value) ?: null; if (!$this->_helper->isEmpty($string) || (is_numeric($numeric) || !$this->_helper->isEmpty($date))) { $key = $this->_item->id . '__' . $this->identifier . '__' . $variant->getId() . '__' . $element->id(); $data[$key] = array('item_id' => $this->_item->id, 'element_id' => $this->identifier, 'param_id' => $element->id(), 'value_s' => $string, 'value_n' => $numeric, 'value_d' => $date, 'variant' => $variant->getId()); } } } return $data; }
/** * @param JBCartVariant $variant * @return array */ protected function getVariantData(JBCartVariant $variant) { $vars = $this->app->jbvars; $data = array(); foreach ($variant->all() as $element) { $value = $element->getSearchData(); $value = $this->_helper->getValue($value); $string = (string) $value; $numeric = is_numeric($value) ? $vars->number($value) : null; $date = $this->_helper->isDate($value) ?: null; if (!$this->_helper->isEmpty($string) || (is_numeric($numeric) || !$this->_helper->isEmpty($date)) || $element->id() == '_value') { $key = $this->_item->id . '__' . $this->identifier . '__' . $variant->getId() . '__' . $element->id(); $data[$key] = array('item_id' => $this->_item->id, 'element_id' => $this->identifier, 'param_id' => $element->id(), 'value_s' => $string, 'value_n' => $numeric, 'value_d' => $date, 'variant' => $variant->getId()); } } return $data; }