Ejemplo n.º 1
0
 public static function transformArray($array, ARSchema $schema)
 {
     $array = parent::transformArray($array, $schema);
     $array['formattedPrice'] = array();
     foreach (self::getApplication()->getCurrencySet() as $id => $currency) {
         $array['formattedPrice'][$id] = $currency->getFormattedPrice(self::getPriceDiff($id, $array['priceDiff']));
     }
     return $array;
 }
Ejemplo n.º 2
0
 public static function transformArray($array, ARSchema $schema)
 {
     $array = parent::transformArray($array, $schema);
     if (isset($array['Parent']) && isset($array['Parent']['type'])) {
         $array['type'] = $array['Parent']['type'];
         $array['isUnlimitedStock'] = $array['Parent']['isUnlimitedStock'];
     }
     $array['isTangible'] = $array['type'] == self::TYPE_TANGIBLE;
     $array['isDownloadable'] = $array['type'] == self::TYPE_DOWNLOADABLE;
     $array['isInventoryTracked'] = self::isInventoryTracked($array['type'], $array['isUnlimitedStock']);
     if ($array['isEnabled']) {
         if ($array['isDownloadable']) {
             $array['isAvailable'] = true;
         } else {
             $array['isAvailable'] = self::isOrderable($array);
         }
     } else {
         $array['isAvailable'] = false;
     }
     if ($array['childSettings']) {
         $array['childSettings'] = unserialize($array['childSettings']);
     }
     if ($array['shippingWeight']) {
         $lb = 0.45359237;
         $oz = 0.0283495231;
         $weight = array();
         $weight['lbs'] = floor($array['shippingWeight'] / $lb);
         $weight['oz'] = ceil(($array['shippingWeight'] - $weight['lbs'] * $lb) / $oz);
         $weight = array_filter($weight);
         $array['shippingWeight_english_values'] = $weight;
         foreach ($weight as $unit => $w) {
             $weight[$unit] = $w . ' ' . $unit;
         }
         $array['shippingWeight_english'] = implode(' ', $weight);
     }
     return $array;
 }
Ejemplo n.º 3
0
 private function getNewsPostEntry($row, $params)
 {
     $row['title'] = unserialize($row['title']);
     $row = MultilingualObject::transformArray($row, ActiveRecord::getSchemaInstance('NewsPost'));
     return array('loc' => $this->router->createFullUrl(createNewsPostUrl(array('news' => $row), $this->application)));
 }
Ejemplo n.º 4
0
 public static function transformArray($array, ARSchema $schema)
 {
     $array = parent::transformArray($array, $schema);
     $path = self::getRelativeImagePath($schema->getName(), $array['ID']);
     if (file_exists($path)) {
         $array['imagePath'] = $path;
     }
     return $array;
 }
Ejemplo n.º 5
0
 public static function transformArray($array, ARSchema $schema, $ownerClass, $ownerField)
 {
     $array = parent::transformArray($array, $schema);
     if (!$array['ID']) {
         return $array;
     }
     $array['paths'] = $array['urls'] = array();
     $app = self::getApplication();
     $router = $app->getRouter();
     foreach (call_user_func(array($schema->getName(), 'getImageSizes')) as $key => $value) {
         $productID = isset($array[$ownerClass]['ID']) ? $array[$ownerClass]['ID'] : (isset($array[$ownerField]) ? $array[$ownerField] : false);
         if (!$productID) {
             break;
         }
         $urlPrefix = null;
         $array['paths'][$key] = self::getRelativePath(call_user_func_array(array($schema->getName(), 'getImagePath'), array($array['ID'], $productID, $key)), $urlPrefix);
         $url = $app->getFullUploadUrl($urlPrefix . $array['paths'][$key]);
         $url = str_replace('/public//public/', '/public/', $url);
         $array['urls'][$key] = $url;
     }
     $array['paths']['original'] = self::getRelativePath(call_user_func_array(array($schema->getName(), 'getImagePath'), array($array['ID'], $productID, 'original')), $urlPrefix);
     return $array;
 }
Ejemplo n.º 6
0
 public static function transformArray($array, ARSchema $schema)
 {
     $array = parent::transformArray($array, $schema);
     // deleted product
     if (!isset($array['Product']) && isset($array['name_lang'])) {
         $array['Product']['name'] = $array['name'];
         $array['Product']['name_lang'] = $array['name_lang'];
         $array['Product']['nameData'] = $array['nameData'];
         if (isset($array['nameData']['sku'])) {
             $array['Product']['sku'] = $array['nameData']['sku'];
         }
     }
     return $array;
 }
Ejemplo n.º 7
0
 public static function transformArray($array, ARSchema $schema)
 {
     $array = parent::transformArray($array, $schema);
     if (!empty($array['name_lang'])) {
         $array['handle'] = createHandleString($array['name_lang']);
     }
     return $array;
 }