Ejemplo n.º 1
0
 private function _initForm()
 {
     $this->view->sites = Axis_Collect_Site::collect();
     $this->view->customerGroups = Axis_Collect_CustomerGroup::collect();
     $this->view->manufactures = Axis_Collect_Manufacturer::collect();
     $languageId = Axis_Locale::getLanguageId();
     $this->view->categoryTrees = Axis::single('catalog/category')->select('*')->addName($languageId)->addKeyWord()->order('cc.lft')->fetchAllAndSortByColumn('site_id');
     $select = Axis::model('catalog/product_option_value')->select('*')->joinLeft('catalog_product_option_value_text', 'cpov.id = cpovt.option_value_id', 'name')->where('cpovt.language_id = ?', $languageId);
     $valuesetValues = array();
     foreach ($select->fetchAll() as $_row) {
         $valuesetValues[$_row['valueset_id']][$_row['id']] = $_row['name'];
     }
     $select = Axis::single('catalog/product_option')->select('*')->addNameAndDescription($languageId);
     $attributes = array();
     foreach ($select->fetchAll() as $_option) {
         if (isset($valuesetValues[$_option['valueset_id']])) {
             $attributes[$_option['id']] = array('name' => $_option['name'], 'option' => $valuesetValues[$_option['valueset_id']]);
         }
     }
     $this->view->attributes = $attributes;
 }
Ejemplo n.º 2
0
 /**
  * Get info about discount + discount rules (condition)
  *
  * @return array
  */
 public function getCustomInfo()
 {
     $array = $this->toArray();
     $rules = Axis::single('discount/eav')->getRulesByDiscountId($this->id);
     if (isset($rules['conditions'])) {
         $array['conditions'] = $rules['conditions'];
     }
     if (isset($rules['category'])) {
         $array['category'] = $rules['category'];
     }
     if (isset($rules['productId'])) {
         $array['productId'] = $rules['productId'];
     }
     if (isset($rules['manufacture'])) {
         $array['manufacture'] = array_intersect($rules['manufacture'], array_keys(Axis_Collect_Manufacturer::collect()));
     }
     if (isset($rules['site'])) {
         $array['site_ids'] = array_intersect($rules['site'], array_keys(Axis_Collect_Site::collect()));
     }
     if (isset($rules['group'])) {
         $array['customer_group_ids'] = array_intersect($rules['group'], array_keys(Axis_Collect_CustomerGroup::collect()));
     }
     if (isset($rules['special'])) {
         $array['special'] = current($rules['special']);
     }
     if (isset($rules['optionId'])) {
         foreach ($rules['optionId'] as $optionId) {
             if (!isset($rules['option[' . $optionId . ']'])) {
                 continue;
             }
             foreach ($rules['option[' . $optionId . ']'] as $optionValueId) {
                 $array['attributes'][] = array('optionId' => $optionId, 'optionValueId' => $optionValueId);
             }
         }
     }
     return $array;
 }