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


PHP Shop::getGroup方法代码示例

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


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

示例1: addSqlShopParams

 /**
  * Add sql params for shops fields - specific to StockAvailable
  *
  * @param array $params Reference to the params array
  * @param int $id_shop Optional : The shop ID
  *
  */
 public static function addSqlShopParams(&$params, $id_shop = null)
 {
     $context = Context::getContext();
     $group_ok = false;
     // if there is no $id_shop, gets the context one
     // get shop group too
     if ($id_shop === null) {
         if (Shop::getContext() == Shop::CONTEXT_GROUP) {
             $shop_group = Shop::getContextShopGroup();
         } else {
             $shop_group = $context->shop->getGroup();
             $id_shop = $context->shop->id;
         }
     } else {
         $shop = new Shop($id_shop);
         $shop_group = $shop->getGroup();
     }
     // if quantities are shared between shops of the group
     if ($shop_group->share_stock) {
         $params['id_shop_group'] = (int) $shop_group->id;
         $params['id_shop'] = 0;
         $group_ok = true;
     } else {
         $params['id_shop_group'] = 0;
     }
     // if no group specific restriction, set simple shop restriction
     if (!$group_ok) {
         $params['id_shop'] = (int) $id_shop;
     }
 }
开发者ID:jicheng17,项目名称:vipinsg,代码行数:37,代码来源:StockAvailable.php

示例2: customerImport

 public function customerImport()
 {
     $customer_exist = false;
     $this->receiveTab();
     $handle = $this->openCsvFile();
     $default_language_id = (int) Configuration::get('PS_LANG_DEFAULT');
     $id_lang = Language::getIdByIso(Tools::getValue('iso_lang'));
     if (!Validate::isUnsignedId($id_lang)) {
         $id_lang = $default_language_id;
     }
     AdminImportController::setLocale();
     for ($current_line = 0; $line = fgetcsv($handle, MAX_LINE_SIZE, $this->separator); $current_line++) {
         if (Tools::getValue('convert')) {
             $line = $this->utf8EncodeArray($line);
         }
         $info = AdminImportController::getMaskedRow($line);
         AdminImportController::setDefaultValues($info);
         if (Tools::getValue('forceIDs') && isset($info['id']) && (int) $info['id']) {
             $customer = new Customer((int) $info['id']);
         } else {
             if (array_key_exists('id', $info) && (int) $info['id'] && Customer::customerIdExistsStatic((int) $info['id'])) {
                 $customer = new Customer((int) $info['id']);
             } else {
                 $customer = new Customer();
             }
         }
         if (array_key_exists('id', $info) && (int) $info['id'] && Customer::customerIdExistsStatic((int) $info['id'])) {
             $current_id_customer = $customer->id;
             $current_id_shop = $customer->id_shop;
             $current_id_shop_group = $customer->id_shop_group;
             $customer_exist = true;
             $customer_groups = $customer->getGroups();
             $addresses = $customer->getAddresses((int) Configuration::get('PS_LANG_DEFAULT'));
         }
         // Group Importation
         if (isset($info['group']) && !empty($info['group'])) {
             foreach (explode($this->multiple_value_separator, $info['group']) as $key => $group) {
                 $group = trim($group);
                 if (empty($group)) {
                     continue;
                 }
                 $id_group = false;
                 if (is_numeric($group) && $group) {
                     $my_group = new Group((int) $group);
                     if (Validate::isLoadedObject($my_group)) {
                         $customer_groups[] = (int) $group;
                     }
                     continue;
                 }
                 $my_group = Group::searchByName($group);
                 if (isset($my_group['id_group']) && $my_group['id_group']) {
                     $id_group = (int) $my_group['id_group'];
                 }
                 if (!$id_group) {
                     $my_group = new Group();
                     $my_group->name = array($id_lang => $group);
                     if ($id_lang != $default_language_id) {
                         $my_group->name = $my_group->name + array($default_language_id => $group);
                     }
                     $my_group->price_display_method = 1;
                     $my_group->add();
                     if (Validate::isLoadedObject($my_group)) {
                         $id_group = (int) $my_group->id;
                     }
                 }
                 if ($id_group) {
                     $customer_groups[] = (int) $id_group;
                 }
             }
         } elseif (empty($info['group']) && isset($customer->id) && $customer->id) {
             $customer_groups = array(0 => Configuration::get('PS_CUSTOMER_GROUP'));
         }
         AdminImportController::arrayWalk($info, array('AdminImportController', 'fillInfo'), $customer);
         if ($customer->passwd) {
             $customer->passwd = Tools::encrypt($customer->passwd);
         }
         $id_shop_list = explode($this->multiple_value_separator, $customer->id_shop);
         $customers_shop = array();
         $customers_shop['shared'] = array();
         $default_shop = new Shop((int) Configuration::get('PS_SHOP_DEFAULT'));
         if (Shop::isFeatureActive() && $id_shop_list) {
             foreach ($id_shop_list as $id_shop) {
                 if (empty($id_shop)) {
                     continue;
                 }
                 $shop = new Shop((int) $id_shop);
                 $group_shop = $shop->getGroup();
                 if ($group_shop->share_customer) {
                     if (!in_array($group_shop->id, $customers_shop['shared'])) {
                         $customers_shop['shared'][(int) $id_shop] = $group_shop->id;
                     }
                 } else {
                     $customers_shop[(int) $id_shop] = $group_shop->id;
                 }
             }
         } else {
             $default_shop = new Shop((int) Configuration::get('PS_SHOP_DEFAULT'));
             $default_shop->getGroup();
             $customers_shop[$default_shop->id] = $default_shop->getGroup()->id;
         }
//.........这里部分代码省略.........
开发者ID:ecssjapan,项目名称:guiding-you-afteropen,代码行数:101,代码来源:AdminImportController.php

示例3: customerImportOne

 protected function customerImportOne($info, $default_language_id, $id_lang, $shop_is_feature_active, $force_ids, $validateOnly = false)
 {
     AdminImportController::setDefaultValues($info);
     if ($force_ids && isset($info['id']) && (int) $info['id']) {
         $customer = new Customer((int) $info['id']);
     } else {
         if (array_key_exists('id', $info) && (int) $info['id'] && Customer::customerIdExistsStatic((int) $info['id'])) {
             $customer = new Customer((int) $info['id']);
         } else {
             $customer = new Customer();
         }
     }
     $customer_exist = false;
     $autodate = true;
     if (array_key_exists('id', $info) && (int) $info['id'] && Customer::customerIdExistsStatic((int) $info['id']) && Validate::isLoadedObject($customer)) {
         $current_id_customer = (int) $customer->id;
         $current_id_shop = (int) $customer->id_shop;
         $current_id_shop_group = (int) $customer->id_shop_group;
         $customer_exist = true;
         $customer_groups = $customer->getGroups();
         $addresses = $customer->getAddresses((int) Configuration::get('PS_LANG_DEFAULT'));
     }
     // Group Importation
     if (isset($info['group']) && !empty($info['group'])) {
         foreach (explode($this->multiple_value_separator, $info['group']) as $key => $group) {
             $group = trim($group);
             if (empty($group)) {
                 continue;
             }
             $id_group = false;
             if (is_numeric($group) && $group) {
                 $my_group = new Group((int) $group);
                 if (Validate::isLoadedObject($my_group)) {
                     $customer_groups[] = (int) $group;
                 }
                 continue;
             }
             $my_group = Group::searchByName($group);
             if (isset($my_group['id_group']) && $my_group['id_group']) {
                 $id_group = (int) $my_group['id_group'];
             }
             if (!$id_group) {
                 $my_group = new Group();
                 $my_group->name = array($id_lang => $group);
                 if ($id_lang != $default_language_id) {
                     $my_group->name = $my_group->name + array($default_language_id => $group);
                 }
                 $my_group->price_display_method = 1;
                 if (!$validateOnly) {
                     $my_group->add();
                     if (Validate::isLoadedObject($my_group)) {
                         $id_group = (int) $my_group->id;
                     }
                 }
             }
             if ($id_group) {
                 $customer_groups[] = (int) $id_group;
             }
         }
     } elseif (empty($info['group']) && isset($customer->id) && $customer->id) {
         $customer_groups = array(0 => Configuration::get('PS_CUSTOMER_GROUP'));
     }
     if (isset($info['date_add']) && !empty($info['date_add'])) {
         $autodate = false;
     }
     AdminImportController::arrayWalk($info, array('AdminImportController', 'fillInfo'), $customer);
     if ($customer->passwd) {
         $customer->passwd = Tools::encrypt($customer->passwd);
     }
     $id_shop_list = explode($this->multiple_value_separator, $customer->id_shop);
     $customers_shop = array();
     $customers_shop['shared'] = array();
     $default_shop = new Shop((int) Configuration::get('PS_SHOP_DEFAULT'));
     if ($shop_is_feature_active && $id_shop_list) {
         foreach ($id_shop_list as $id_shop) {
             if (empty($id_shop)) {
                 continue;
             }
             $shop = new Shop((int) $id_shop);
             $group_shop = $shop->getGroup();
             if ($group_shop->share_customer) {
                 if (!in_array($group_shop->id, $customers_shop['shared'])) {
                     $customers_shop['shared'][(int) $id_shop] = $group_shop->id;
                 }
             } else {
                 $customers_shop[(int) $id_shop] = $group_shop->id;
             }
         }
     } else {
         $default_shop = new Shop((int) Configuration::get('PS_SHOP_DEFAULT'));
         $default_shop->getGroup();
         $customers_shop[$default_shop->id] = $default_shop->getGroup()->id;
     }
     //set temporary for validate field
     $customer->id_shop = $default_shop->id;
     $customer->id_shop_group = $default_shop->getGroup()->id;
     if (isset($info['id_default_group']) && !empty($info['id_default_group']) && !is_numeric($info['id_default_group'])) {
         $info['id_default_group'] = trim($info['id_default_group']);
         $my_group = Group::searchByName($info['id_default_group']);
         if (isset($my_group['id_group']) && $my_group['id_group']) {
//.........这里部分代码省略.........
开发者ID:M03G,项目名称:PrestaShop,代码行数:101,代码来源:AdminImportController.php

示例4: customerImport

 public function customerImport()
 {
     $customer_exist = false;
     $this->receiveTab();
     $handle = $this->openCsvFile();
     AdminImportController::setLocale();
     for ($current_line = 0; $line = fgetcsv($handle, MAX_LINE_SIZE, $this->separator); $current_line++) {
         if (Tools::getValue('convert')) {
             $line = $this->utf8EncodeArray($line);
         }
         $info = AdminImportController::getMaskedRow($line);
         AdminImportController::setDefaultValues($info);
         if (array_key_exists('id', $info) && (int) $info['id'] && Customer::customerIdExistsStatic((int) $info['id'])) {
             $customer = new Customer((int) $info['id']);
             $current_id_customer = $customer->id;
             $current_id_shop = $customer->id_shop;
             $current_id_shop_group = $customer->id_shop_group;
             $customer_exist = true;
             $customer_groups = $customer->getGroups();
             $addresses = $customer->getAddresses((int) Configuration::get('PS_LANG_DEFAULT'));
             foreach ($customer_groups as $key => $group) {
                 if ($group == $customer->id_default_group) {
                     unset($customer_groups[$key]);
                 }
             }
         } else {
             $customer = new Customer();
         }
         AdminImportController::arrayWalk($info, array('AdminImportController', 'fillInfo'), $customer);
         if ($customer->passwd) {
             $customer->passwd = Tools::encrypt($customer->passwd);
         }
         $id_shop_list = explode($this->multiple_value_separator, $customer->id_shop);
         $customers_shop = array();
         $customers_shop['shared'] = array();
         $default_shop = new Shop((int) Configuration::get('PS_SHOP_DEFAULT'));
         if (Shop::isFeatureActive() && $id_shop_list) {
             foreach ($id_shop_list as $id_shop) {
                 $shop = new Shop((int) $id_shop);
                 $group_shop = $shop->getGroup();
                 if ($group_shop->share_customer) {
                     if (!in_array($group_shop->id, $customers_shop['shared'])) {
                         $customers_shop['shared'][(int) $id_shop] = $group_shop->id;
                     }
                 } else {
                     $customers_shop[(int) $id_shop] = $group_shop->id;
                 }
             }
         } else {
             $default_shop = new Shop((int) Configuration::get('PS_SHOP_DEFAULT'));
             $default_shop->getGroup();
             $customers_shop[$default_shop->id] = $default_shop->getGroup()->id;
         }
         //set temporally for validate field
         $customer->id_shop = $default_shop->id;
         $customer->id_shop_group = $default_shop->getGroup()->id;
         $res = true;
         if (($field_error = $customer->validateFields(UNFRIENDLY_ERROR, true)) === true && ($lang_field_error = $customer->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true) {
             foreach ($customers_shop as $id_shop => $id_group) {
                 if ($id_shop == 'shared') {
                     foreach ($id_group as $key => $id) {
                         $customer->id_shop = (int) $key;
                         $customer->id_shop_group = (int) $id;
                         if ($customer_exist && ($current_id_shop_group == $id || in_array($current_id_shop, ShopGroup::getShopsFromGroup($id)))) {
                             $customer->id = $current_id_customer;
                             $res &= $customer->update();
                         } else {
                             unset($customer->id);
                             $res &= $customer->add();
                             if (isset($customer_groups)) {
                                 $customer->addGroups($customer_groups);
                             }
                             if (isset($addresses)) {
                                 foreach ($addresses as $address) {
                                     $address['id_customer'] = $customer->id;
                                     unset($address['country'], $address['state'], $address['state_iso'], $address['id_address']);
                                     Db::getInstance()->insert('address', $address);
                                 }
                             }
                         }
                     }
                 } else {
                     $customer->id_shop = $id_shop;
                     $customer->id_shop_group = $id_group;
                     if ($customer_exist && $id_shop == $current_id_shop) {
                         $customer->id = $current_id_customer;
                         $res &= $customer->update();
                     } else {
                         unset($customer->id);
                         $res &= $customer->add();
                         if (isset($customer_groups)) {
                             $customer->addGroups($customer_groups);
                         }
                         if (isset($addresses)) {
                             foreach ($addresses as $address) {
                                 $address['id_customer'] = $customer->id;
                                 unset($address['country'], $address['state'], $address['state_iso'], $address['id_address']);
                                 Db::getInstance()->insert('address', $address);
                             }
                         }
//.........这里部分代码省略.........
开发者ID:jicheng17,项目名称:vipinsg,代码行数:101,代码来源:AdminImportController.php


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