当前位置: 首页>>代码示例>>PHP>>正文


PHP Product::getAttributeCombinations方法代码示例

本文整理汇总了PHP中Product::getAttributeCombinations方法的典型用法代码示例。如果您正苦于以下问题:PHP Product::getAttributeCombinations方法的具体用法?PHP Product::getAttributeCombinations怎么用?PHP Product::getAttributeCombinations使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Product的用法示例。


在下文中一共展示了Product::getAttributeCombinations方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: hookDisplayFooterProduct

 public function hookDisplayFooterProduct()
 {
     global $smarty;
     global $cookie;
     global $db;
     $this_product = new Product($_GET['id_product']);
     $combinations = $this_product->getAttributeCombinations($cookie->id_lang);
     $enable = 0;
     for ($i = 0; $i < count($combinations); $i++) {
         if (strpos($combinations[$i]["group_name"], "Color") !== False) {
             $enable = 1;
         }
         $attributeId = new Attribute($combinations[$i]['id_attribute']);
         $combinations[$i]["color_value"] = $attributeId->color == '0' ? 'img/co/' . $combinations[$i]['id_attribute'] . '.jpg' : $attributeId->color;
     }
     $smarty->assign('enable', $enable);
     $smarty->assign('product', $this_product);
     $smarty->assign('combinations', $combinations);
     return $this->display(__FILE__, 'c1b291cb852.tpl');
 }
开发者ID:jelocartel,项目名称:c1b291cb852,代码行数:20,代码来源:c1b291cb852.php

示例2: attributeImportOne


//.........这里部分代码省略.........
                        // sets the proper id (corresponding to the right key)
                        $obj->id_attribute_group = $groups_attributes[$key]['id'];
                        $obj->name[$default_language] = str_replace('\\n', '', str_replace('\\r', '', $attribute));
                        $obj->position = !$position && isset($groups[$group]) ? Attribute::getHigherPosition($groups[$group]) + 1 : $position;
                        if (($field_error = $obj->validateFields(UNFRIENDLY_ERROR, true)) === true && ($lang_field_error = $obj->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true) {
                            if (!$validateOnly) {
                                $obj->add();
                                $obj->associateTo($id_shop_list);
                                $attributes[$group . '_' . $attribute] = $obj->id;
                            }
                        } else {
                            $this->errors[] = ($field_error !== true ? $field_error : '') . (isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : '');
                        }
                    }
                    $info['minimal_quantity'] = isset($info['minimal_quantity']) && $info['minimal_quantity'] ? (int) $info['minimal_quantity'] : 1;
                    $info['wholesale_price'] = str_replace(',', '.', $info['wholesale_price']);
                    $info['price'] = str_replace(',', '.', $info['price']);
                    $info['ecotax'] = str_replace(',', '.', $info['ecotax']);
                    $info['weight'] = str_replace(',', '.', $info['weight']);
                    $info['available_date'] = Validate::isDate($info['available_date']) ? $info['available_date'] : null;
                    if (!Validate::isEan13($info['ean13'])) {
                        $this->warnings[] = sprintf($this->trans('EAN13 "%1s" has incorrect value for product with id %2d.', array(), 'Admin.Parameters.Notification'), $info['ean13'], $product->id);
                        $info['ean13'] = '';
                    }
                    if ($info['default_on'] && !$validateOnly) {
                        $product->deleteDefaultAttributes();
                    }
                    // if a reference is specified for this product, get the associate id_product_attribute to UPDATE
                    if (isset($info['reference']) && !empty($info['reference'])) {
                        $id_product_attribute = Combination::getIdByReference($product->id, strval($info['reference']));
                        // updates the attribute
                        if ($id_product_attribute && !$validateOnly) {
                            // gets all the combinations of this product
                            $attribute_combinations = $product->getAttributeCombinations($default_language);
                            foreach ($attribute_combinations as $attribute_combination) {
                                if ($id_product_attribute && in_array($id_product_attribute, $attribute_combination)) {
                                    // FIXME: ~3s/declinaison
                                    $product->updateAttribute($id_product_attribute, (double) $info['wholesale_price'], (double) $info['price'], (double) $info['weight'], 0, Configuration::get('PS_USE_ECOTAX') ? (double) $info['ecotax'] : 0, $id_image, strval($info['reference']), strval($info['ean13']), (int) $info['default_on'], 0, strval($info['upc']), (int) $info['minimal_quantity'], $info['available_date'], null, $id_shop_list);
                                    $id_product_attribute_update = true;
                                    if (isset($info['supplier_reference']) && !empty($info['supplier_reference'])) {
                                        $product->addSupplierReference($product->id_supplier, $id_product_attribute, $info['supplier_reference']);
                                    }
                                    // until here
                                }
                            }
                        }
                    }
                    // if no attribute reference is specified, creates a new one
                    if (!$id_product_attribute && !$validateOnly) {
                        $id_product_attribute = $product->addCombinationEntity((double) $info['wholesale_price'], (double) $info['price'], (double) $info['weight'], 0, Configuration::get('PS_USE_ECOTAX') ? (double) $info['ecotax'] : 0, (int) $info['quantity'], $id_image, strval($info['reference']), 0, strval($info['ean13']), (int) $info['default_on'], 0, strval($info['upc']), (int) $info['minimal_quantity'], $id_shop_list, $info['available_date']);
                        if (isset($info['supplier_reference']) && !empty($info['supplier_reference'])) {
                            $product->addSupplierReference($product->id_supplier, $id_product_attribute, $info['supplier_reference']);
                        }
                    }
                    // fills our attributes array, in order to add the attributes to the product_attribute afterwards
                    if (isset($attributes[$group . '_' . $attribute])) {
                        $attributes_to_add[] = (int) $attributes[$group . '_' . $attribute];
                    }
                    // after insertion, we clean attribute position and group attribute position
                    if (!$validateOnly) {
                        $obj = new Attribute();
                        $obj->cleanPositions((int) $id_attribute_group, false);
                        AttributeGroup::cleanPositions();
                    }
                }
            }
开发者ID:M03G,项目名称:PrestaShop,代码行数:67,代码来源:AdminImportController.php

示例3: renderListAttributes

 /**
  * @param Product $product
  * @param Currency|array|int $currency
  * @return string
  */
 public function renderListAttributes($product, $currency)
 {
     $this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?')));
     $this->addRowAction('edit');
     $this->addRowAction('default');
     $this->addRowAction('delete');
     $default_class = 'highlighted';
     $this->fields_list = array('attributes' => array('title' => $this->l('Attribute - value pair'), 'align' => 'left'), 'price' => array('title' => $this->l('Impact on price'), 'type' => 'price', 'align' => 'left'), 'weight' => array('title' => $this->l('Impact on weight'), 'align' => 'left'), 'reference' => array('title' => $this->l('Reference'), 'align' => 'left'), 'ean13' => array('title' => $this->l('EAN-13'), 'align' => 'left'), 'upc' => array('title' => $this->l('UPC'), 'align' => 'left'));
     if ($product->id) {
         /* Build attributes combinations */
         $combinations = $product->getAttributeCombinations($this->context->language->id);
         $groups = array();
         $comb_array = array();
         if (is_array($combinations)) {
             $combination_images = $product->getCombinationImages($this->context->language->id);
             foreach ($combinations as $k => $combination) {
                 $price_to_convert = Tools::convertPrice($combination['price'], $currency);
                 $price = Tools::displayPrice($price_to_convert, $currency);
                 $comb_array[$combination['id_product_attribute']]['id_product_attribute'] = $combination['id_product_attribute'];
                 $comb_array[$combination['id_product_attribute']]['attributes'][] = array($combination['group_name'], $combination['attribute_name'], $combination['id_attribute']);
                 $comb_array[$combination['id_product_attribute']]['wholesale_price'] = $combination['wholesale_price'];
                 $comb_array[$combination['id_product_attribute']]['price'] = $price;
                 $comb_array[$combination['id_product_attribute']]['weight'] = $combination['weight'] . Configuration::get('PS_WEIGHT_UNIT');
                 $comb_array[$combination['id_product_attribute']]['unit_impact'] = $combination['unit_price_impact'];
                 $comb_array[$combination['id_product_attribute']]['reference'] = $combination['reference'];
                 $comb_array[$combination['id_product_attribute']]['ean13'] = $combination['ean13'];
                 $comb_array[$combination['id_product_attribute']]['upc'] = $combination['upc'];
                 $comb_array[$combination['id_product_attribute']]['id_image'] = isset($combination_images[$combination['id_product_attribute']][0]['id_image']) ? $combination_images[$combination['id_product_attribute']][0]['id_image'] : 0;
                 $comb_array[$combination['id_product_attribute']]['available_date'] = strftime($combination['available_date']);
                 $comb_array[$combination['id_product_attribute']]['default_on'] = $combination['default_on'];
                 if ($combination['is_color_group']) {
                     $groups[$combination['id_attribute_group']] = $combination['group_name'];
                 }
             }
         }
         if (isset($comb_array)) {
             foreach ($comb_array as $id_product_attribute => $product_attribute) {
                 $list = '';
                 /* In order to keep the same attributes order */
                 asort($product_attribute['attributes']);
                 foreach ($product_attribute['attributes'] as $attribute) {
                     $list .= $attribute[0] . ' - ' . $attribute[1] . ', ';
                 }
                 $list = rtrim($list, ', ');
                 $comb_array[$id_product_attribute]['image'] = $product_attribute['id_image'] ? new Image($product_attribute['id_image']) : false;
                 $comb_array[$id_product_attribute]['available_date'] = $product_attribute['available_date'] != 0 ? date('Y-m-d', strtotime($product_attribute['available_date'])) : '0000-00-00';
                 $comb_array[$id_product_attribute]['attributes'] = $list;
                 $comb_array[$id_product_attribute]['name'] = $list;
                 if ($product_attribute['default_on']) {
                     $comb_array[$id_product_attribute]['class'] = $default_class;
                 }
             }
         }
     }
     foreach ($this->actions_available as $action) {
         if (!in_array($action, $this->actions) && isset($this->{$action}) && $this->{$action}) {
             $this->actions[] = $action;
         }
     }
     $helper = new HelperList();
     $helper->identifier = 'id_product_attribute';
     $helper->table_id = 'combinations-list';
     $helper->token = $this->token;
     $helper->currentIndex = self::$currentIndex;
     $helper->no_link = true;
     $helper->simple_header = true;
     $helper->show_toolbar = false;
     $helper->shopLinkType = $this->shopLinkType;
     $helper->actions = $this->actions;
     $helper->list_skip_actions = $this->list_skip_actions;
     $helper->colorOnBackground = true;
     $helper->override_folder = $this->tpl_folder . 'combination/';
     return $helper->generateList($comb_array, $this->fields_list);
 }
开发者ID:Rohit-jn,项目名称:hotelcommerce,代码行数:79,代码来源:AdminProductsController.php

示例4: generateXML

 public function generateXML($cron)
 {
     $shop_url = 'http://' . Tools::getHttpHost(false, true) . __PS_BASE_URI__;
     $id_lang = (int) Configuration::get('PS_LANG_DEFAULT');
     $currency_default = new Currency(Configuration::get('PS_CURRENCY_DEFAULT'));
     $this->currency_iso = $currency_default->iso_code;
     $country = new Country(Configuration::get('PS_COUNTRY_DEFAULT'));
     $this->country_name = $country->name;
     $currencies = Currency::getCurrencies();
     $categories = Category::getCategories($id_lang, false, false);
     $yamarket_set_combinations = Configuration::get('YA_MARKET_SET_COMBINATIONS');
     $this->yamarket_availability = Configuration::get('YA_MARKET_DOSTUPNOST');
     $this->gzip = Configuration::get('YA_MARKET_SET_GZIP');
     /*-----------------------------------------------------------------------------*/
     $cats = array();
     if ($c = Configuration::get('YA_MARKET_CATEGORIES')) {
         $uc = unserialize($c);
         if (is_array($uc)) {
             $cats = $uc;
         }
     }
     $yml = new Yml();
     $yml->yml('utf-8');
     $yml->setShop(Configuration::get('PS_SHOP_NAME'), Configuration::get('YA_MARKET_NAME'), $shop_url);
     if (Configuration::get('YA_MARKET_SET_ALLCURRENCY')) {
         foreach ($currencies as $currency) {
             $yml->addCurrency($currency['iso_code'], (double) $currency_default->conversion_rate / (double) $currency['conversion_rate']);
         }
         unset($currencies);
     } else {
         $yml->addCurrency($currency_default->iso_code, (double) $currency_default->conversion_rate);
     }
     foreach ($categories as $category) {
         if (!in_array($category['id_category'], $cats) || $category['id_category'] == 1) {
             continue;
         }
         if (Configuration::get('YA_MARKET_SET_NACTIVECAT')) {
             if (!$category['active']) {
                 continue;
             }
         }
         if (Configuration::get('YA_MARKET_CATALL')) {
             if (in_array($category['id_category'], $cats)) {
                 $yml->addCategory($category['name'], $category['id_category'], $category['id_parent']);
             }
         } else {
             $yml->addCategory($category['name'], $category['id_category'], $category['id_parent']);
         }
     }
     foreach ($yml->categories as $cat) {
         $category_object = new Category($cat['id']);
         $products = $category_object->getProducts($id_lang, 1, 10000);
         if ($products) {
             foreach ($products as $product) {
                 if ($product['id_category_default'] != $cat['id']) {
                     continue;
                 }
                 $data = array();
                 if ($yamarket_set_combinations && !Configuration::get('YA_MARKET_SHORT')) {
                     $product_object = new Product($product['id_product'], false, $id_lang);
                     $combinations = $product_object->getAttributeCombinations($id_lang);
                 } else {
                     $combinations = false;
                 }
                 if (is_array($combinations) && count($combinations) > 0) {
                     $comb_array = array();
                     foreach ($combinations as $combination) {
                         $comb_array[$combination['id_product_attribute']]['id_product_attribute'] = $combination['id_product_attribute'];
                         $comb_array[$combination['id_product_attribute']]['price'] = Product::getPriceStatic($product['id_product'], true, $combination['id_product_attribute']);
                         $comb_array[$combination['id_product_attribute']]['reference'] = $combination['reference'];
                         $comb_array[$combination['id_product_attribute']]['ean13'] = $combination['ean13'];
                         $comb_array[$combination['id_product_attribute']]['quantity'] = $combination['quantity'];
                         $comb_array[$combination['id_product_attribute']]['minimal_quantity'] = $combination['minimal_quantity'];
                         $comb_array[$combination['id_product_attribute']]['weight'] = $combination['weight'];
                         $comb_array[$combination['id_product_attribute']]['attributes'][$combination['group_name']] = $combination['attribute_name'];
                         if (!isset($comb_array[$combination['id_product_attribute']]['comb_url'])) {
                             $comb_array[$combination['id_product_attribute']]['comb_url'] = '';
                         }
                         $comb_array[$combination['id_product_attribute']]['comb_url'] .= '/' . Tools::str2url($combination['group_name']) . '-' . str_replace(Configuration::get('PS_ATTRIBUTE_ANCHOR_SEPARATOR'), '_', Tools::str2url(str_replace(array(',', '.'), '-', $combination['attribute_name'])));
                     }
                     foreach ($comb_array as $combination) {
                         $data = $this->makeData($product, $combination);
                         $available = $data['available'];
                         unset($data['available']);
                         if (!empty($data) && $data['price'] != 0) {
                             $yml->addOffer($data['id'], $data, $available);
                         }
                     }
                 } else {
                     $data = $this->makeData($product);
                     $available = $data['available'];
                     unset($data['available']);
                     if (!empty($data) && (int) $data['price'] != 0) {
                         $yml->addOffer($data['id'], $data, $available);
                     }
                 }
                 unset($data);
             }
         }
         unset($product);
//.........这里部分代码省略.........
开发者ID:handaehan,项目名称:yandex-money-cms-prestashop,代码行数:101,代码来源:yamodule.php

示例5: attributeImport


//.........这里部分代码省略.........
                        } else {
                            $this->errors[] = ($field_error !== true ? $field_error : '') . (isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : '');
                        }
                        // fils groups attributes
                        $id_attribute_group = $obj->id;
                        $groups_attributes[$key]['id'] = $id_attribute_group;
                    } else {
                        $id_attribute_group = $groups[$group];
                        $groups_attributes[$key]['id'] = $id_attribute_group;
                    }
                }
            }
            // inits attribute
            $id_product_attribute = 0;
            $id_product_attribute_update = false;
            $attributes_to_add = array();
            // for each attribute
            if (isset($info['attribute'])) {
                foreach (explode($this->multiple_value_separator, $info['attribute']) as $key => $attribute) {
                    $tab_attribute = explode(':', $attribute);
                    $attribute = trim($tab_attribute[0]);
                    // if position is filled
                    if (isset($tab_attribute[1])) {
                        $position = trim($tab_attribute[1]);
                    } else {
                        $position = false;
                    }
                    if (isset($groups_attributes[$key])) {
                        $group = $groups_attributes[$key]['group'];
                        if (!isset($attributes[$group . '_' . $attribute]) && count($groups_attributes[$key]) == 2) {
                            $id_attribute_group = $groups_attributes[$key]['id'];
                            $obj = new Attribute();
                            // sets the proper id (corresponding to the right key)
                            $obj->id_attribute_group = $groups_attributes[$key]['id'];
                            $obj->name[$default_language] = str_replace('\\n', '', str_replace('\\r', '', $attribute));
                            $obj->position = !$position && isset($groups[$group]) ? Attribute::getHigherPosition($groups[$group]) + 1 : $position;
                            if (($field_error = $obj->validateFields(UNFRIENDLY_ERROR, true)) === true && ($lang_field_error = $obj->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true) {
                                $obj->add();
                                $obj->associateTo($id_shop_list);
                                $attributes[$group . '_' . $attribute] = $obj->id;
                            } else {
                                $this->errors[] = ($field_error !== true ? $field_error : '') . (isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : '');
                            }
                        }
                        $info['minimal_quantity'] = isset($info['minimal_quantity']) && $info['minimal_quantity'] ? (int) $info['minimal_quantity'] : 1;
                        $info['wholesale_price'] = str_replace(',', '.', $info['wholesale_price']);
                        $info['price'] = str_replace(',', '.', $info['price']);
                        $info['ecotax'] = str_replace(',', '.', $info['ecotax']);
                        $info['weight'] = str_replace(',', '.', $info['weight']);
                        // if a reference is specified for this product, get the associate id_product_attribute to UPDATE
                        if (isset($info['reference']) && !empty($info['reference'])) {
                            $id_product_attribute = Combination::getIdByReference($product->id, strval($info['reference']));
                            // updates the attribute
                            if ($id_product_attribute) {
                                // gets all the combinations of this product
                                $attribute_combinations = $product->getAttributeCombinations($default_language);
                                foreach ($attribute_combinations as $attribute_combination) {
                                    if ($id_product_attribute && in_array($id_product_attribute, $attribute_combination)) {
                                        $product->updateAttribute($id_product_attribute, (double) $info['wholesale_price'], (double) $info['price'], (double) $info['weight'], 0, (double) $info['ecotax'], $id_image, strval($info['reference']), strval($info['ean13']), (int) $info['default_on'], 0, strval($info['upc']), (int) $info['minimal_quantity'], 0, null, $id_shop_list);
                                        $id_product_attribute_update = true;
                                    }
                                }
                            }
                        }
                        // if no attribute reference is specified, creates a new one
                        if (!$id_product_attribute) {
                            $id_product_attribute = $product->addCombinationEntity((double) $info['wholesale_price'], (double) $info['price'], (double) $info['weight'], 0, (double) $info['ecotax'], (int) $info['quantity'], $id_image, strval($info['reference']), 0, strval($info['ean13']), (int) $info['default_on'], 0, strval($info['upc']), (int) $info['minimal_quantity'], $id_shop_list);
                        }
                        // fills our attributes array, in order to add the attributes to the product_attribute afterwards
                        if (isset($attributes[$group . '_' . $attribute])) {
                            $attributes_to_add[] = (int) $attributes[$group . '_' . $attribute];
                        }
                        // after insertion, we clean attribute position and group attribute position
                        $obj = new Attribute();
                        $obj->cleanPositions((int) $id_attribute_group, false);
                        AttributeGroup::cleanPositions();
                    }
                }
            }
            $product->checkDefaultAttributes();
            if (!$product->cache_default_attribute) {
                Product::updateDefaultAttribute($product->id);
            }
            if ($id_product_attribute) {
                // now adds the attributes in the attribute_combination table
                if ($id_product_attribute_update) {
                    Db::getInstance()->execute('
						DELETE FROM ' . _DB_PREFIX_ . 'product_attribute_combination
						WHERE id_product_attribute = ' . (int) $id_product_attribute);
                }
                foreach ($attributes_to_add as $attribute_to_add) {
                    Db::getInstance()->execute('
						INSERT IGNORE INTO ' . _DB_PREFIX_ . 'product_attribute_combination (id_attribute, id_product_attribute)
						VALUES (' . (int) $attribute_to_add . ',' . (int) $id_product_attribute . ')');
                }
                StockAvailable::setQuantity($product->id, $id_product_attribute, (int) $info['quantity']);
            }
        }
        $this->closeCsvFile($handle);
    }
开发者ID:FAVHYAN,项目名称:a3workout,代码行数:101,代码来源:AdminImportController.php

示例6: hookdisplayProductAttributesPL

 public function hookdisplayProductAttributesPL($params)
 {
     if (!Configuration::get($this->config_name . '_productl_size')) {
         return;
     }
     $product = new Product($params['productid']);
     $combinations = $product->getAttributeCombinations($this->context->language->id);
     $avaiable_sizes = array();
     $checked_sizes = array();
     foreach ($combinations as $combination) {
         if ($combination['quantity'] > 0 && $combination['id_attribute_group'] == (int) Configuration::get($this->config_name . '_attribute_size')) {
             if (!in_array($combination['id_attribute'], $checked_sizes)) {
                 $avaiable_sizes[$combination['id_product_attribute']]['attribute_name'] = $combination['attribute_name'];
                 $checked_sizes[] = $combination['id_attribute'];
             }
         }
     }
     $this->smarty->assign('combinations', $avaiable_sizes);
     return $this->display(__FILE__, 'combinations.tpl', $this->getCacheId((int) $params['productid']));
 }
开发者ID:evgrishin,项目名称:se1614,代码行数:20,代码来源:iqitsizeguide.php

示例7: updateCombinantionsForPrestashop

 /**
  * Updates product combinations on Prestashop.
  * 
  * @param integer $id_product
  * @param string $url_photo
  * @param array $triple_cod_col_siz
  * @param array $array_combinations
  * @param integer $language
  * @return bool
  * @see $this->createAttributeGroups
  * @see $this->setArrayElementForLinkRewrite
  * @see $this->getCodeColor
  * @see PrestashopImageHandler getIdImageByName()
  * @see PrestashopImageHandler insertImageInPrestashop()
  *
  */
 private function updateCombinantionsForPrestashop($id_product, $url_photo, $triple_cod_col_siz, $array_combinations, $language = 1)
 {
     $product = new Product((int) $id_product);
     $id_new_images = array();
     $price = '0.000';
     //(float)$product->price;
     $reference = $product->reference;
     $id_supplier = (int) $product->id_supplier;
     foreach ($triple_cod_col_siz as $triple) {
         $array_attributes_and_values = $array_combinations[$triple];
         $attributes = $array_attributes_and_values["Attributi"];
         $values = $array_attributes_and_values["Valori"];
         $image = trim($array_attributes_and_values["Immagine"]);
         $quantity = (int) $array_attributes_and_values["Qta"];
         $variable_tmp_attributes = explode(",", $attributes);
         $variable_tmp_values = explode(",", $values);
         $id_attributes_for_combinations = array();
         $flag_just_exist_color = 1;
         $flag_just_exist_size = 1;
         for ($i = 0; $i < sizeof($variable_tmp_attributes); $i++) {
             $code = "";
             if ($variable_tmp_values[$i] != "") {
                 $id_attribute_group = $this->createAttributeGroups($variable_tmp_attributes[$i], $language);
                 $id_attributes_for_not_repeat = $this->getAttributeColorAndSize($variable_tmp_values[$i], $language);
                 if (strtolower($variable_tmp_attributes[$i]) === "colore" || strtolower($variable_tmp_attributes[$i]) === "colori") {
                     $product_attribute_for_not_reply = $product->getAttributeCombinations($language);
                     if (empty($product_attribute_for_not_reply)) {
                         if ($id_attributes_for_not_repeat === '-1') {
                             $code = $this->getCodeColor(strtolower($variable_tmp_values[$i]));
                             if ($code != "") {
                                 $code = "#" . $code;
                                 $attribute_for_product = new Attribute();
                                 $attribute_for_product->name = $this->setArrayElementForLinkRewrite($variable_tmp_values[$i], true, $language);
                                 $attribute_for_product->color = $code;
                                 $attribute_for_product->id_attribute_group = $id_attribute_group;
                                 $attribute_for_product->add();
                                 array_push($id_attributes_for_combinations, $attribute_for_product->id);
                             }
                         } else {
                             array_push($id_attributes_for_combinations, (int) $id_attributes_for_not_repeat);
                         }
                     } else {
                         $flag = 1;
                         foreach ($product_attribute_for_not_reply as $more_attributes) {
                             if ($more_attributes['attribute_name'] === $variable_tmp_values[$i]) {
                                 array_push($id_attributes_for_combinations, (int) $more_attributes['id_attribute']);
                                 $flag = 0;
                                 $flag_just_exist_color = 0;
                                 break;
                             }
                         }
                         if ($flag) {
                             if ($id_attributes_for_not_repeat === '-1') {
                                 $code = $this->getCodeColor(strtolower($variable_tmp_values[$i]));
                                 if ($code != "") {
                                     $code = "#" . $code;
                                     $attribute_for_product = new Attribute();
                                     $attribute_for_product->name = $this->setArrayElementForLinkRewrite($variable_tmp_values[$i], true, $language);
                                     $attribute_for_product->color = $code;
                                     $attribute_for_product->id_attribute_group = $id_attribute_group;
                                     $attribute_for_product->add();
                                     array_push($id_attributes_for_combinations, $attribute_for_product->id);
                                 }
                             } else {
                                 array_push($id_attributes_for_combinations, (int) $id_attributes_for_not_repeat);
                             }
                         }
                     }
                 }
                 if (strtolower($variable_tmp_attributes[$i]) === "taglia" || strtolower($variable_tmp_attributes[$i]) === "taglie") {
                     $product_attribute_for_not_reply = $product->getAttributeCombinations($language);
                     if (empty($product_attribute_for_not_reply)) {
                         if ($id_attributes_for_not_repeat === '-1') {
                             $attribute_for_product = new Attribute();
                             $attribute_for_product->name = $this->setArrayElementForLinkRewrite($variable_tmp_values[$i], true, $language);
                             $attribute_for_product->id_attribute_group = $id_attribute_group;
                             $attribute_for_product->add();
                             array_push($id_attributes_for_combinations, $attribute_for_product->id);
                         } else {
                             array_push($id_attributes_for_combinations, (int) $id_attributes_for_not_repeat);
                         }
                     } else {
                         $flag = 1;
                         foreach ($product_attribute_for_not_reply as $more_attributes) {
//.........这里部分代码省略.........
开发者ID:valucifer,项目名称:S-SoldP-Pal,代码行数:101,代码来源:PrestashopProducts.php

示例8: getProductSizes

 /**
  * @param \Product $product
  *
  * @return null|string
  * @throws \Exception
  * @author Panagiotis Vagenas <pan.vagenas@gmail.com>
  * @since 150213
  */
 protected function getProductSizes(\Product &$product)
 {
     $mapSizes = $this->Options->getValue('map_size');
     if (empty($mapSizes)) {
         return null;
     }
     $sizes = array();
     foreach ($product->getAttributeCombinations($this->defaultLang) as $key => $comp) {
         if ($comp['is_color_group'] || !in_array($comp['id_attribute'], $mapSizes) || $comp['quantity'] < 1 && !$this->backOrdersAllowed($product)) {
             continue;
         }
         $size = $this->sanitizeVariationString($comp['attribute_name']);
         if ($this->isValidSizeString($size)) {
             array_push($sizes, $size);
         }
     }
     return implode(', ', array_unique($sizes));
 }
开发者ID:panvagenas,项目名称:prestashop-skroutz-xml-feed,代码行数:26,代码来源:Skroutz.php

示例9: getAlertCategories

 private function getAlertCategories()
 {
     $alert = '';
     $sql_getCatNonMultiSku = "SELECT * FROM " . _DB_PREFIX_ . "ebay_category_configuration AS ecc\n\t\t\t\t\t\tINNER JOIN " . _DB_PREFIX_ . "ebay_category AS ec ON ecc.id_ebay_category = ec.id_ebay_category";
     $CatNonMultiSku = Db::getInstance()->ExecuteS($sql_getCatNonMultiSku);
     $catWithProblem = array();
     foreach ($CatNonMultiSku as $cat) {
         if ($cat['is_multi_sku'] != 1 && $this->findIfCategoryParentIsMultiSku($cat['id_category_ref']) != 1) {
             $categorie = new Category($cat['id_category']);
             $products = $categorie->getProductsWs($this->id_lang, 0, 300);
             $catProblem = 0;
             foreach ($products as $productArray) {
                 $product = new Product($productArray['id']);
                 $combinations = $this->isVersionOneDotFive() ? $product->getAttributeCombinations($this->context->cookie->id_lang) : $product->getAttributeCombinaisons($this->context->cookie->id_lang);
                 if (count($combinations) > 0 && $catProblem == 0) {
                     $catWithProblem[] = $cat['name'];
                     $catProblem = 1;
                 }
             }
         }
     }
     $var = '';
     $j = 0;
     foreach ($catWithProblem as $cat) {
         if ($j != 0) {
             $var .= ', ';
         }
         $var .= $cat;
         $j++;
     }
     if (count($catWithProblem) > 0) {
         if (count($catWithProblem == 1)) {
             $alert = '<b>' . $this->l('You have chosen eBay category : ') . $var . $this->l(' which does not support multivariation products. Each variation of a product will generate a new product in eBay') . '</b>';
         } else {
             $alert = '<b>' . $this->l('You have chosen eBay categories : ') . $var . $this->l(' which do not support multivariation products. Each variation of a product will generate a new product in eBay') . '</b>';
         }
     }
     return $alert;
 }
开发者ID:Evil1991,项目名称:PrestaShop-1.4,代码行数:39,代码来源:ebay.php

示例10: generateFile

 private function generateFile($lang, $id_curr, $id_shop)
 {
     $id_lang = (int) $lang['id_lang'];
     $curr = new Currency($id_curr);
     $this->shop = new Shop($id_shop);
     $root = Category::getRootCategory($id_lang, $this->shop);
     $this->id_root = $root->id_category;
     // Get module configuration for this shop
     $this->module_conf = $this->getConfigFieldsValues($id_shop);
     // Init categories special attributes :
     // Google's matching category, gender, age_group, color_group, material, pattern, size...
     $this->getGCategValues($id_lang, $id_shop);
     // Init file_path value
     if ($this->module_conf['gen_file_in_root']) {
         $generate_file_path = dirname(__FILE__) . '/../../' . $this->_getOutputFileName($lang['iso_code'], $curr->iso_code, $id_shop);
     } else {
         $generate_file_path = dirname(__FILE__) . '/export/' . $this->_getOutputFileName($lang['iso_code'], $curr->iso_code, $id_shop);
     }
     if ($this->shop->name == 'Prestashop') {
         $this->shop->name = Configuration::get('PS_SHOP_NAME');
     }
     // Google Shopping XML
     $xml = '<?xml version="1.0" encoding="' . self::CHARSET . '" ?>' . "\n";
     $xml .= '<rss version="2.0" xmlns:g="http://base.google.com/ns/1.0">' . "\n\n";
     $xml .= '<channel>' . "\n";
     // Shop name
     $xml .= '<title><![CDATA[' . $this->shop->name . ']]></title>' . "\n";
     // Shop description
     $xml .= '<description><![CDATA[' . $this->getShopDescription($id_lang, $id_shop) . ']]></description>' . "\n";
     $xml .= '<link href="' . htmlspecialchars($this->uri, self::REPLACE_FLAGS, self::CHARSET, false) . '" rel="alternate" type="text/html"/>' . "\n";
     $xml .= '<image>' . "\n";
     $xml .= '<url>' . htmlspecialchars($this->context->link->getMediaLink(_PS_IMG_ . Configuration::get('PS_LOGO')), self::REPLACE_FLAGS, self::CHARSET, false) . '</url>' . "\n";
     $xml .= '<link>' . htmlspecialchars($this->uri, self::REPLACE_FLAGS, self::CHARSET, false) . '</link>' . "\n";
     $xml .= '</image>' . "\n";
     $xml .= '<modified>' . date('Y-m-d') . ' T01:01:01Z</modified>' . "\n";
     $xml .= '<author>' . "\n" . '<name>' . htmlspecialchars(Configuration::get('PS_SHOP_NAME'), self::REPLACE_FLAGS, self::CHARSET, false) . '</name>' . "\n" . '</author>' . "\n\n";
     $googleshoppingfile = fopen($generate_file_path, 'w');
     // Add UTF-8 byte order mark
     fwrite($googleshoppingfile, pack("CCC", 0xef, 0xbb, 0xbf));
     // File header
     fwrite($googleshoppingfile, $xml);
     $sql = 'SELECT DISTINCT p.*, pl.*, ps.id_category_default as category_default, gc.*, glc.tax_included, gl.* ' . 'FROM ' . _DB_PREFIX_ . 'product p ' . 'INNER JOIN ' . _DB_PREFIX_ . 'product_lang pl ON pl.id_product = p.id_product ' . 'INNER JOIN ' . _DB_PREFIX_ . 'product_shop ps ON ps.id_product = p.id_product ' . 'INNER JOIN ' . _DB_PREFIX_ . 'category c ON c.id_category = p.id_category_default ' . 'INNER JOIN ' . _DB_PREFIX_ . 'gshoppingflux gc ON gc.id_gcategory = ps.id_category_default ' . 'INNER JOIN ' . _DB_PREFIX_ . 'gshoppingflux_lc glc ON glc.`id_glang` = ' . $id_lang . ' ' . 'INNER JOIN ' . _DB_PREFIX_ . 'gshoppingflux_lang gl ON gl.id_gcategory = ps.id_category_default ' . 'WHERE `p`.`price` > 0 AND `p`.`active` = 1 AND `c`.`active` = 1 AND `gc`.`export` = 1 ' . 'AND `pl`.`id_lang` = ' . $id_lang . ' AND `gl`.`id_lang` = ' . $id_lang;
     // Multishops filter
     if (Configuration::get('PS_MULTISHOP_FEATURE_ACTIVE') && count(Shop::getShops(true, null, true)) > 1) {
         $sql .= ' AND `gc`.`id_shop` = ' . $id_shop . ' AND `pl`.`id_shop` = ' . $id_shop . ' AND `ps`.`id_shop` = ' . $id_shop . ' AND `gl`.`id_shop` = ' . $id_shop;
     }
     // Check EAN13
     if ($this->module_conf['no_gtin'] != 1) {
         $sql .= ' AND `p`.`ean13` != "" AND `p`.`ean13` != 0';
     }
     // Check BRAND
     if ($this->module_conf['no_brand'] != 1) {
         $sql .= ' AND `p`.`id_manufacturer` != "" AND `p`.`id_manufacturer` != 0';
     }
     $sql .= ' GROUP BY `p`.`id_product`;';
     $products = Db::getInstance()->ExecuteS($sql);
     $this->nb_total_products = 0;
     $this->nb_not_exported_products = 0;
     $this->nb_combinations = 0;
     $this->nb_prd_w_attr = array();
     foreach ($products as $product) {
         $p = new Product($product['id_product'], true, $id_lang, $id_shop, $this->context);
         $attributeCombinations = null;
         if ($this->module_conf['export_attributes'] == 1) {
             $attributeCombinations = $p->getAttributeCombinations($id_lang);
         }
         if ($this->module_conf['mpn_type'] == 'reference' && !empty($product['reference'])) {
             $product['pid'] = $product['reference'];
         } else {
             if ($this->module_conf['mpn_type'] == 'supplier_reference' && !empty($product['supplier_reference'])) {
                 $product['pid'] = $product['supplier_reference'];
             } else {
                 $product['pid'] = $product['id_product'];
             }
         }
         $product['gid'] = $product['pid'];
         $xml_googleshopping = $this->getItemXML($product, $lang, $id_curr, $id_shop);
         fwrite($googleshoppingfile, $xml_googleshopping);
         if (count($attributeCombinations) > 0 && $this->module_conf['export_attributes'] == 1) {
             $attr = array();
             foreach ($attributeCombinations as $a => $attribute) {
                 $attr[$attribute['id_product_attribute']][$attribute['id_attribute_group']] = $attribute;
             }
             $combinum = 0;
             foreach ($attr as $id_attr => $v) {
                 foreach ($v as $k => $a) {
                     foreach ($this->categories_values[$product['id_gcategory']]['gcat_color[]'] as $c) {
                         if ($k == $c) {
                             $product['color'] = $a['attribute_name'];
                         }
                     }
                     foreach ($this->categories_values[$product['id_gcategory']]['gcat_material[]'] as $c) {
                         if ($k == $c) {
                             $product['material'] = $a['attribute_name'];
                         }
                     }
                     foreach ($this->categories_values[$product['id_gcategory']]['gcat_pattern[]'] as $c) {
                         if ($k == $c) {
                             $product['pattern'] = $a['attribute_name'];
                         }
//.........这里部分代码省略.........
开发者ID:ecommercebox,项目名称:gshoppingflux,代码行数:101,代码来源:gshoppingflux.php

示例11: attributeImport


//.........这里部分代码省略.........
                    }
                    if (isset($groups_attributes[$key])) {
                        $group = $groups_attributes[$key]['group'];
                        if (!isset($attributes[$group . '_' . $attribute]) && count($groups_attributes[$key]) == 2) {
                            $id_attribute_group = $groups_attributes[$key]['id'];
                            $obj = new Attribute();
                            $obj->id_attribute_group = $groups_attributes[$key]['id'];
                            $obj->name[$default_language] = str_replace('\\n', '', str_replace('\\r', '', $attribute));
                            $obj->position = !$position && isset($groups[$group]) ? Attribute::getHigherPosition($groups[$group]) + 1 : $position;
                            if (($field_error = $obj->validateFields(UNFRIENDLY_ERROR, true)) === true && ($lang_field_error = $obj->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true) {
                                $obj->add();
                                $obj->associateTo($id_shop_list);
                                $attributes[$group . '_' . $attribute] = $obj->id;
                            } else {
                                $this->errors[] = ($field_error !== true ? $field_error : '') . (isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : '');
                            }
                        }
                        $info['minimal_quantity'] = isset($info['minimal_quantity']) && $info['minimal_quantity'] ? (int) $info['minimal_quantity'] : 1;
                        $info['wholesale_price'] = str_replace(',', '.', $info['wholesale_price']);
                        $info['price'] = str_replace(',', '.', $info['price']);
                        $info['ecotax'] = str_replace(',', '.', $info['ecotax']);
                        $info['weight'] = str_replace(',', '.', $info['weight']);
                        $info['available_date'] = Validate::isDate($info['available_date']) ? $info['available_date'] : null;
                        if (!Validate::isEan13($info['ean13'])) {
                            $this->warnings[] = sprintf(Tools::displayError('EAN13 "%1s" has incorrect value for product with id %2d.'), $info['ean13'], $product->id);
                            $info['ean13'] = '';
                        }
                        if ($info['default_on']) {
                            $product->deleteDefaultAttributes();
                        }
                        if (isset($info['reference']) && !empty($info['reference'])) {
                            $id_product_attribute = Combination::getIdByReference($product->id, (string) $info['reference']);
                            if ($id_product_attribute) {
                                $attribute_combinations = $product->getAttributeCombinations($default_language);
                                foreach ($attribute_combinations as $attribute_combination) {
                                    if ($id_product_attribute && in_array($id_product_attribute, $attribute_combination)) {
                                        $product->updateAttribute($id_product_attribute, (double) $info['wholesale_price'], (double) $info['price'], (double) $info['weight'], 0, Configuration::get('PS_USE_ECOTAX') ? (double) $info['ecotax'] : 0, $id_image, (string) $info['reference'], (string) $info['ean13'], (int) $info['default_on'], 0, (string) $info['upc'], (int) $info['minimal_quantity'], $info['available_date'], null, $id_shop_list);
                                        $id_product_attribute_update = true;
                                        if (isset($info['supplier_reference']) && !empty($info['supplier_reference'])) {
                                            $product->addSupplierReference($product->id_supplier, $id_product_attribute, $info['supplier_reference']);
                                        }
                                    }
                                }
                            }
                        }
                        if (!$id_product_attribute) {
                            $id_product_attribute = $product->addCombinationEntity((double) $info['wholesale_price'], (double) $info['price'], (double) $info['weight'], 0, Configuration::get('PS_USE_ECOTAX') ? (double) $info['ecotax'] : 0, (int) $info['quantity'], $id_image, (string) $info['reference'], 0, (string) $info['ean13'], (int) $info['default_on'], 0, (string) $info['upc'], (int) $info['minimal_quantity'], $id_shop_list, $info['available_date']);
                            if (isset($info['supplier_reference']) && !empty($info['supplier_reference'])) {
                                $product->addSupplierReference($product->id_supplier, $id_product_attribute, $info['supplier_reference']);
                            }
                        }
                        if (isset($attributes[$group . '_' . $attribute])) {
                            $attributes_to_add[] = (int) $attributes[$group . '_' . $attribute];
                        }
                        $obj = new Attribute();
                        $obj->cleanPositions((int) $id_attribute_group, false);
                        AttributeGroup::cleanPositions();
                    }
                }
            }
            $product->checkDefaultAttributes();
            if (!$product->cache_default_attribute) {
                Product::updateDefaultAttribute($product->id);
            }
            if ($id_product_attribute) {
                if ($id_product_attribute_update) {
开发者ID:Oldwo1f,项目名称:yakaboutique,代码行数:67,代码来源:AdminImportController.php

示例12: initContent

 /**
  * Assign template vars related to page content
  * @see FrontController::initContent()
  */
 public function initContent()
 {
     parent::initContent();
     if (!$this->errors) {
         if (Pack::isPack((int) $this->product->id) && !Pack::isInStock((int) $this->product->id)) {
             $this->product->quantity = 0;
         }
         $this->product->description = $this->transformDescriptionWithImg($this->product->description);
         // Assign to the template the id of the virtual product. "0" if the product is not downloadable.
         $this->context->smarty->assign('virtual', ProductDownload::getIdFromIdProduct((int) $this->product->id));
         $this->context->smarty->assign('customizationFormTarget', Tools::safeOutput(urldecode($_SERVER['REQUEST_URI'])));
         if (Tools::isSubmit('submitCustomizedDatas')) {
             // If cart has not been saved, we need to do it so that customization fields can have an id_cart
             // We check that the cookie exists first to avoid ghost carts
             if (!$this->context->cart->id && isset($_COOKIE[$this->context->cookie->getName()])) {
                 $this->context->cart->add();
                 $this->context->cookie->id_cart = (int) $this->context->cart->id;
             }
             $this->pictureUpload();
             $this->textRecord();
             $this->formTargetFormat();
         } elseif (Tools::getIsset('deletePicture') && !$this->context->cart->deleteCustomizationToProduct($this->product->id, Tools::getValue('deletePicture'))) {
             $this->errors[] = Tools::displayError('An error occurred while deleting the selected picture.');
         }
         $pictures = array();
         $text_fields = array();
         if ($this->product->customizable) {
             $files = $this->context->cart->getProductCustomization($this->product->id, Product::CUSTOMIZE_FILE, true);
             foreach ($files as $file) {
                 $pictures['pictures_' . $this->product->id . '_' . $file['index']] = $file['value'];
             }
             $texts = $this->context->cart->getProductCustomization($this->product->id, Product::CUSTOMIZE_TEXTFIELD, true);
             foreach ($texts as $text_field) {
                 $text_fields['textFields_' . $this->product->id . '_' . $text_field['index']] = str_replace('<br />', "\n", $text_field['value']);
             }
         }
         $this->context->smarty->assign(array('pictures' => $pictures, 'textFields' => $text_fields));
         $this->product->customization_required = false;
         $customization_fields = $this->product->customizable ? $this->product->getCustomizationFields($this->context->language->id) : false;
         if (is_array($customization_fields)) {
             foreach ($customization_fields as $customization_field) {
                 if ($this->product->customization_required = $customization_field['required']) {
                     break;
                 }
             }
         }
         // Assign template vars related to the category + execute hooks related to the category
         $this->assignCategory();
         // Assign template vars related to the price and tax
         $this->assignPriceAndTax();
         // Assign template vars related to the images
         $this->assignImages();
         // Assign attribute groups to the template
         $this->assignAttributesGroups();
         // Assign attributes combinations to the template
         $this->assignAttributesCombinations();
         // Pack management
         $pack_items = $this->product->cache_is_pack ? Pack::getItemTable($this->product->id, $this->context->language->id, true) : array();
         $this->context->smarty->assign('packItems', $pack_items);
         $this->context->smarty->assign('packs', Pack::getPacksTable($this->product->id, $this->context->language->id, true, 1));
         if (isset($this->category->id) && $this->category->id) {
             $return_link = Tools::safeOutput($this->context->link->getCategoryLink($this->category));
         } else {
             $return_link = 'javascript: history.back();';
         }
         $category_id = $this->category->id;
         if ($category_id === 13) {
             $foundations = array();
             $foundations_ids = array(28, 29, 30, 31);
             foreach ($foundations_ids as $id) {
                 $product = new Product($id, true, $this->context->language->id);
                 $cover = $product->getCover($id);
                 $foundations[$id]['img_src'] = $this->context->link->getImageLink($product->link_rewrite, $cover['id_image'], 'large_default');
                 $foundations[$id]['name'] = $product->name;
                 $foundations[$id]['href'] = $this->context->link->getProductLink($product->id);
                 $combListArr = $product->getAttributeCombinations($this->context->language->id);
                 $foundations[$id]['combs'] = $combListArr;
                 $foundations[$id]['price'] = $product->price;
             }
             //  echo '<pre>'.print_r($foundations,true).'</pre>';
             $this->context->smarty->assign(array('foundations' => $foundations));
             // echo '<pre>'.print_r(get_class_methods($product),true).'</pre>';
             unset($product);
         }
         $this->context->smarty->assign(array('stock_management' => Configuration::get('PS_STOCK_MANAGEMENT'), 'customizationFields' => $customization_fields, 'accessories' => $this->product->getAccessories($this->context->language->id), 'return_link' => $return_link, 'product' => $this->product, 'product_manufacturer' => new Manufacturer((int) $this->product->id_manufacturer, $this->context->language->id), 'token' => Tools::getToken(false), 'features' => $this->product->getFrontFeatures($this->context->language->id), 'attachments' => $this->product->cache_has_attachments ? $this->product->getAttachments($this->context->language->id) : array(), 'allow_oosp' => $this->product->isAvailableWhenOutOfStock((int) $this->product->out_of_stock), 'last_qties' => (int) Configuration::get('PS_LAST_QTIES'), 'HOOK_EXTRA_LEFT' => Hook::exec('displayLeftColumnProduct'), 'HOOK_EXTRA_RIGHT' => Hook::exec('displayRightColumnProduct'), 'HOOK_PRODUCT_OOS' => Hook::exec('actionProductOutOfStock', array('product' => $this->product)), 'HOOK_PRODUCT_ACTIONS' => Hook::exec('displayProductButtons', array('product' => $this->product)), 'HOOK_PRODUCT_TAB' => Hook::exec('displayProductTab', array('product' => $this->product)), 'HOOK_PRODUCT_TAB_CONTENT' => Hook::exec('displayProductTabContent', array('product' => $this->product)), 'HOOK_PRODUCT_CONTENT' => Hook::exec('displayProductContent', array('product' => $this->product)), 'display_qties' => (int) Configuration::get('PS_DISPLAY_QTIES'), 'display_ht' => !Tax::excludeTaxeOption(), 'jqZoomEnabled' => Configuration::get('PS_DISPLAY_JQZOOM'), 'ENT_NOQUOTES' => ENT_NOQUOTES, 'outOfStockAllowed' => (int) Configuration::get('PS_ORDER_OUT_OF_STOCK'), 'errors' => $this->errors, 'body_classes' => array($this->php_self . '-' . $this->product->id, $this->php_self . '-' . $this->product->link_rewrite, 'category-' . (isset($this->category) ? $this->category->id : ''), 'category-' . (isset($this->category) ? $this->category->getFieldByLang('link_rewrite') : '')), 'display_discount_price' => Configuration::get('PS_DISPLAY_DISCOUNT_PRICE')));
     }
     $this->setTemplate(_PS_THEME_DIR_ . 'product.tpl');
 }
开发者ID:Beattle,项目名称:perrino-shop,代码行数:92,代码来源:ProductController.php

示例13: generate

 public function generate($cron = false)
 {
     self::setCurrency();
     include 'classes/ymlCatalog.php';
     //Язык по умолчанию
     $id_lang = (int) Configuration::get('PS_LANG_DEFAULT');
     //Валюта по умолчанию
     $currency_default = new Currency($this->context->cookie->id_currency);
     $this->currency_iso = $currency_default->iso_code;
     //Адрес магазина
     $shop_url = 'http://' . Tools::getHttpHost(false, true) . __PS_BASE_URI__;
     //Категории для экспорта
     $yamarket_с_categories = unserialize(Configuration::get('yamarket_с_categories'));
     //$yamarket_с_suppliers = unserialize(Configuration::get('yamarket_с_supplier'));
     $yamarket_с_combinations = Configuration::get('yamarket_с_combinations');
     $this->yamarket_с_availability = Configuration::get('yamarket_с_availability');
     $this->yamarket_с_shipping = unserialize(Configuration::get('yamarket_с_shipping'));
     //создаем новый магазин
     $catalog = new ymlCatalog();
     $catalog->gzip = Configuration::get('yamarket_с_gzip');
     $shop = new ymlShop();
     $shop->name = Configuration::get('yamarket_с_shop');
     $shop->company = Configuration::get('yamarket_с_company');
     $shop->url = $shop_url;
     $shop->platform = 'PrestaShop';
     $shop->version = _PS_VERSION_;
     $shop->agency = 'PrestaLab';
     $shop->email = 'admin@prestalab.ru';
     //Валюты
     $shop->startTag(ymlCurrency::$collectionName);
     if (Configuration::get('yamarket_с_currencies')) {
         $currencies = Currency::getCurrencies();
         foreach ($currencies as $currency) {
             $shop->add(new ymlCurrency($currency['iso_code'], (double) $currency['conversion_rate']));
         }
         unset($currencies);
     } else {
         $shop->add(new ymlCurrency($currency_default->iso_code, (double) $currency_default->conversion_rate));
     }
     $shop->endTag(ymlCurrency::$collectionName);
     //Категории
     $categories = Category::getCategories($id_lang, false, false);
     $shop->startTag(ymlCategory::$collectionName);
     foreach ($categories as $category) {
         if ($category['active'] && in_array($category['id_category'], $yamarket_с_categories)) {
             $shop->add(new ymlCategory($category['id_category'], $category['name'], $category['id_parent']));
         }
     }
     $shop->endTag(ymlCategory::$collectionName);
     //Стоимость доставки
     $shop->addString('<local_delivery_cost>' . Configuration::get('yamarket_с_shippingcost') . '</local_delivery_cost>');
     //Товары
     $shop->startTag(ymlOffer::$collectionName);
     foreach ($categories as $category) {
         if ($category['active'] && in_array($category['id_category'], $yamarket_с_categories)) {
             $category_object = new Category($category['id_category']);
             $products = $category_object->getProducts($id_lang, 1, 10000);
             if ($products) {
                 foreach ($products as $product) {
                     if ($product['id_category_default'] != $category['id_category']) {
                         continue;
                     }
                     //						if (count($yamarket_с_suppliers)&&(!in_array($product['id_supplier'], $yamarket_с_suppliers)))
                     //							continue;
                     //Для комбинаций
                     if ($yamarket_с_combinations) {
                         $product_object = new Product($product['id_product'], false, $id_lang);
                         $combinations = $product_object->getAttributeCombinations($id_lang);
                     } else {
                         $combinations = false;
                     }
                     if (is_array($combinations) && count($combinations) > 0) {
                         $comb_array = array();
                         foreach ($combinations as $combination) {
                             $comb_array[$combination['id_product_attribute']]['id_product_attribute'] = $combination['id_product_attribute'];
                             $comb_array[$combination['id_product_attribute']]['price'] = Product::getPriceStatic($product['id_product'], true, $combination['id_product_attribute']);
                             $comb_array[$combination['id_product_attribute']]['reference'] = $combination['reference'];
                             $comb_array[$combination['id_product_attribute']]['ean13'] = $combination['ean13'];
                             $comb_array[$combination['id_product_attribute']]['quantity'] = $combination['quantity'];
                             $comb_array[$combination['id_product_attribute']]['attributes'][$combination['group_name']] = $combination['attribute_name'];
                             $comb_array[$combination['id_product_attribute']]['oldprice'] = $product['orderprice'] + $combination['price'];
                             if (!isset($comb_array[$combination['id_product_attribute']]['comb_url'])) {
                                 $comb_array[$combination['id_product_attribute']]['comb_url'] = '';
                             }
                             $comb_array[$combination['id_product_attribute']]['comb_url'] .= '/' . (self::combinationUrlPrepare($combination['group_name']) . '-' . self::combinationUrlPrepare($combination['attribute_name']));
                         }
                         foreach ($comb_array as $combination) {
                             self::_addProduct($shop, $product, $combination);
                         }
                     } else {
                         self::_addProduct($shop, $product);
                     }
                 }
             }
             unset($product);
         }
     }
     unset($categories);
     $shop->endTag(ymlOffer::$collectionName);
     $catalog->add($shop);
//.........这里部分代码省略.........
开发者ID:Beattle,项目名称:perrino-shop,代码行数:101,代码来源:yamarket.php

示例14: _getAlertCategories

    private function _getAlertCategories()
    {
        $alert = '';
        $cat_with_problem = array();
        $sql_get_cat_non_multi_sku = 'SELECT * FROM ' . _DB_PREFIX_ . 'ebay_category_configuration AS ecc
			INNER JOIN ' . _DB_PREFIX_ . 'ebay_category AS ec ON ecc.id_ebay_category = ec.id_ebay_category';
        foreach (Db::getInstance()->ExecuteS($sql_get_cat_non_multi_sku) as $cat) {
            if ($cat['is_multi_sku'] != 1 && EbayCategory::getInheritedIsMultiSku($cat['id_category_ref']) != 1) {
                $catProblem = 0;
                $category = new Category($cat['id_category']);
                $products = $category->getProductsWs($this->ebay_country->getIdLang(), 0, 300);
                foreach ($products as $product_ar) {
                    $product = new Product($product_ar['id']);
                    $combinations = version_compare(_PS_VERSION_, '1.5', '>') ? $product->getAttributeCombinations($this->context->cookie->id_lang) : $product->getAttributeCombinaisons($this->context->cookie->id_lang);
                    if (count($combinations) > 0 && !$catProblem) {
                        $cat_with_problem[] = $cat['name'];
                        $catProblem = 1;
                    }
                }
            }
        }
        $var = implode(', ', $cat_with_problem);
        if (count($cat_with_problem) > 0) {
            if (count($cat_with_problem == 1)) {
                // RAPH: pb here in the test. Potential typo
                $alert = '<b>' . $this->l('You have chosen eBay category : ') . $var . $this->l(' which does not support multivariation products. Each variation of a product will generate a new product in eBay') . '</b>';
            } else {
                $alert = '<b>' . $this->l('You have chosen eBay categories : ') . $var . $this->l(' which do not support multivariation products. Each variation of a product will generate a new product in eBay') . '</b>';
            }
        }
        return $alert;
    }
开发者ID:ventsiwad,项目名称:presta_addons,代码行数:32,代码来源:ebay.php

示例15: getProductAttributeCombinations

 /**
  * function to get all necessary data of products combinations
  * @param $products An array of products data
  * @return array products combinations
  */
 public function getProductAttributeCombinations($products)
 {
     $combinations = array();
     foreach ($products as $product) {
         // load product object
         $product = new Product($product['id_product'], $this->context->language->id);
         // get the product combinations data
         // create array combinations with key = id_product
         $combinations[$product->id] = $product->getAttributeCombinations($this->context->language->id);
     }
     return $combinations;
 }
开发者ID:satanicman,项目名称:Pizzushi.loc,代码行数:17,代码来源:CategoryController.php


注:本文中的Product::getAttributeCombinations方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。