Ejemplo n.º 1
0
 /**
  * Customizing weight fields
  *
  * @param array $data
  * @return array
  */
 protected function customizeWeightFormat(array $data)
 {
     $model = $this->locator->getProduct();
     $modelId = $model->getId();
     $weightFields = [ProductAttributeInterface::CODE_WEIGHT];
     foreach ($weightFields as $fieldCode) {
         $path = $modelId . '/' . self::DATA_SOURCE_DEFAULT . '/' . $fieldCode;
         $data = $this->arrayManager->replace($path, $data, $this->formatNumber($this->arrayManager->get($path, $data)));
     }
     return $data;
 }
 /**
  * Customizing number fields
  *
  * @param array $data
  * @return array
  */
 protected function customizeNumberFormat(array $data)
 {
     $model = $this->locator->getProduct();
     $modelId = $model->getId();
     $numberFields = [ProductAttributeInterface::CODE_PRICE, ProductAttributeInterface::CODE_WEIGHT, ProductAttributeInterface::CODE_SPECIAL_PRICE, ProductAttributeInterface::CODE_COST];
     foreach ($numberFields as $fieldCode) {
         $path = $modelId . '/' . self::DATA_SOURCE_DEFAULT . '/' . $fieldCode;
         $number = (double) $this->arrayManager->get($path, $data);
         $data = $this->arrayManager->replace($path, $data, $this->formatNumber($number));
     }
     return $data;
 }
 /**
  * Format float number to have two digits after delimiter
  *
  * @param string $path
  * @param array $data
  * @return array
  */
 protected function formatFloat($path, array $data)
 {
     $value = $this->arrayManager->get($path, $data);
     if (is_numeric($value)) {
         $data = $this->arrayManager->replace($path, $data, number_format($value, 2, '.', ''));
     }
     return $data;
 }
Ejemplo n.º 4
0
 /**
  * Format float number to have two digits after delimiter
  *
  * @param string $path
  * @param array $data
  * @return array
  */
 protected function formatPriceByPath($path, array $data)
 {
     $value = $this->arrayManager->get($path, $data);
     if (is_numeric($value)) {
         $data = $this->arrayManager->replace($path, $data, $this->formatPrice($value));
     }
     return $data;
 }