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


PHP ShopGroup::getShopsFromGroup方法代码示例

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


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

示例1: customerImportOne


//.........这里部分代码省略.........
                 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']) {
             $info['id_default_group'] = (int) $my_group['id_group'];
         }
     }
     $my_group = new Group($customer->id_default_group);
     if (!Validate::isLoadedObject($my_group)) {
         $customer->id_default_group = (int) Configuration::get('PS_CUSTOMER_GROUP');
     }
     $customer_groups[] = (int) $customer->id_default_group;
     $customer_groups = array_flip(array_flip($customer_groups));
     // Bug when updating existing user that were csv-imported before...
     if (isset($customer->date_upd) && $customer->date_upd == '0000-00-00 00:00:00') {
         $customer->date_upd = date('Y-m-d H:i:s');
     }
     $res = false;
     if (($field_error = $customer->validateFields(UNFRIENDLY_ERROR, true)) === true && ($lang_field_error = $customer->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true) {
         $res = true;
         foreach ($customers_shop as $id_shop => $id_group) {
             $customer->force_id = (bool) $force_ids;
             if ($id_shop == 'shared') {
                 foreach ($id_group as $key => $id) {
                     $customer->id_shop = (int) $key;
                     $customer->id_shop_group = (int) $id;
                     if ($customer_exist && ((int) $current_id_shop_group == (int) $id || in_array($current_id_shop, ShopGroup::getShopsFromGroup($id)))) {
                         $customer->id = (int) $current_id_customer;
                         $res &= $validateOnly || $customer->update();
                     } else {
                         $res &= $validateOnly || $customer->add($autodate);
                         if (!$validateOnly && 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, false, false);
                             }
                         }
                     }
                     if ($res && !$validateOnly && isset($customer_groups)) {
                         $customer->updateGroup($customer_groups);
                     }
                 }
             } else {
                 $customer->id_shop = $id_shop;
                 $customer->id_shop_group = $id_group;
                 if ($customer_exist && (int) $id_shop == (int) $current_id_shop) {
                     $customer->id = (int) $current_id_customer;
                     $res &= $validateOnly || $customer->update();
                 } else {
                     $res &= $validateOnly || $customer->add($autodate);
                     if (!$validateOnly && 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, false, false);
                         }
                     }
                 }
                 if ($res && !$validateOnly && isset($customer_groups)) {
                     $customer->updateGroup($customer_groups);
                 }
             }
         }
     }
     if (isset($customer_groups)) {
         unset($customer_groups);
     }
     if (isset($current_id_customer)) {
         unset($current_id_customer);
     }
     if (isset($current_id_shop)) {
         unset($current_id_shop);
     }
     if (isset($current_id_shop_group)) {
         unset($current_id_shop_group);
     }
     if (isset($addresses)) {
         unset($addresses);
     }
     if (!$res) {
         $this->errors[] = sprintf(Tools::displayError('%1$s (ID: %2$s) cannot be ' . ($validateOnly ? 'validated' : 'saved')), $info['email'], isset($info['id']) && !empty($info['id']) ? $info['id'] : 'null');
         $this->errors[] = ($field_error !== true ? $field_error : '') . (isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : '') . Db::getInstance()->getMsgError();
     }
 }
开发者ID:M03G,项目名称:PrestaShop,代码行数:101,代码来源:AdminImportController.php

示例2: Product

         Shop::setContext(Shop::CONTEXT_SHOP, $id);
         echo "-Context is set to " . $type . $id . " ";
         break;
     default:
         Shop::setContext(Shop::CONTEXT_ALL, null);
         echo "-Context is set to " . $type . " ";
 }
 //code v2.4.1
 $id_product = (int) Tools::getValue('id_product');
 $id_lang = (int) Context::getContext()->language->id;
 //$product = new Product($id_product, false, $id_lang,$id_shop_source,$context); //version 5.2 - Ne duplique que dans une seule langue
 $product = new Product($id_product, false, null, $id_shop_source, $context);
 //version 5.3  All languages
 //Class product:  function __construct($id_product = null, $full = false, $id_lang = null, $id_shop = null, Context $context = null)
 if (empty($product->price) && Shop::getContext() == Shop::CONTEXT_GROUP) {
     $shops = ShopGroup::getShopsFromGroup(Shop::getContextShopGroupID());
     foreach ($shops as $shop) {
         if ($product->isAssociatedToShop($shop['id_shop'])) {
             $product_price = new Product($id_product_old, false, null, $shop['id_shop']);
             $product->price = $product_price->price;
         }
     }
 }
 if (Validate::isLoadedObject($product)) {
     $id_product_old = $product->id;
     for ($i = 1; $i <= $quantity; $i++) {
         echo $i;
         unset($product->id);
         unset($product->id_product);
         $product->indexed = 0;
         $product->active = 0;
开发者ID:EliosIT,项目名称:PS_AchatFilet,代码行数:31,代码来源:duplication.php

示例3: customerImport


//.........这里部分代码省略.........
         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;
         }
         //set temporally 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']) {
                 $info['id_default_group'] = (int) $my_group['id_group'];
             }
         }
         $my_group = new Group($customer->id_default_group);
         if (!Validate::isLoadedObject($my_group)) {
             $customer->id_default_group = (int) Configuration::get('PS_CUSTOMER_GROUP');
         }
         $customer_groups[] = (int) $customer->id_default_group;
         $customer_groups = array_flip(array_flip($customer_groups));
         $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) {
                 $customer->force_id = (bool) Tools::getValue('forceIDs');
                 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 {
                             $res &= $customer->add();
                             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);
                                 }
                             }
                         }
                         if ($res && isset($customer_groups)) {
                             $customer->updateGroup($customer_groups);
                         }
                     }
                 } 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 {
                         $res &= $customer->add();
                         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);
                             }
                         }
                     }
                     if ($res && isset($customer_groups)) {
                         $customer->updateGroup($customer_groups);
                     }
                 }
             }
         }
         unset($customer_groups);
         $customer_exist = false;
         if (!$res) {
             $this->errors[] = sprintf(Tools::displayError('%1$s (ID: %2$s) cannot be saved'), $info['email'], isset($info['id']) && !empty($info['id']) ? $info['id'] : 'null');
             $this->errors[] = ($field_error !== true ? $field_error : '') . (isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : '') . Db::getInstance()->getMsgError();
         }
     }
     $this->closeCsvFile($handle);
 }
开发者ID:ecssjapan,项目名称:guiding-you-afteropen,代码行数:101,代码来源:AdminImportController.php

示例4: postProcess

 public function postProcess()
 {
     $id_shops = array();
     if (Tools::isSubmit('mass_csv_form_submit')) {
         if (Shop::getContext() == Shop::CONTEXT_ALL) {
             $shops = Shop::getShops();
             if (!empty($shops)) {
                 foreach ($shops as $s) {
                     $id_shops[] = $s['id_shop'];
                 }
             }
         } elseif (Shop::getContext() == Shop::CONTEXT_GROUP) {
             $shopid = Shop::getContextShopGroupID(true);
             $shops = ShopGroup::getShopsFromGroup($shopid);
             if (!empty($shops)) {
                 foreach ($shops as $s) {
                     $id_shops[] = $s['id_shop'];
                 }
             }
         }
         if (empty($id_shops)) {
             $id_shops[] = Shop::getContextShopID();
         }
         $id_shops = array_unique($id_shops);
         if (is_uploaded_file($_FILES['csv_file']['tmp_name'])) {
             $mimes = array('application/vnd.ms-excel', 'text/plain', 'text/csv', 'text/tsv');
             if (!in_array($_FILES['csv_file']['type'], $mimes)) {
                 $this->errors[] = Tools::displayError($this->l('Error : Problem with file upload. Please retry or check your file.'));
                 return false;
             }
             if (move_uploaded_file($_FILES['csv_file']['tmp_name'], $this->mod->cache_dir . $_FILES['csv_file']['name'])) {
                 $old_file_name = $_FILES['csv_file']['name'];
                 $csv_content = Tools::file_get_contents($this->mod->cache_dir . $old_file_name);
                 $array = $this->csvToArray($csv_content);
                 if (empty($array)) {
                     $this->errors[] = Tools::displayError($this->l('Error : Problem with file upload. Please retry or check your file.'));
                     parent::postProcess();
                     return false;
                 }
                 foreach ($array as $value) {
                     if (!empty($value[0])) {
                         $new = !empty($value[1]) ? trim($value[1]) : '/';
                         $type = !empty($value[2]) ? trim($value[2]) : '301';
                         $regex = !empty($value[3]) ? (int) $value[3] : 0;
                         $redirect = new Redirect();
                         $redirect->old = trim($value[0]);
                         $redirect->new = $new;
                         $redirect->type = $type;
                         $redirect->regex = (bool) $regex;
                         $redirect->active = true;
                         $redirect->add();
                         /*foreach ($id_shops as $v) {
                               $db->execute('INSERT INTO `'._DB_PREFIX_.'redirect_shop` (`id_redirect_shop`,`id_redirect`, `id_shop`) VALUES (NULL,'.(int)$redirect->id.','.(int)$v.')');
                           }*/
                     }
                 }
             }
             Tools::redirectAdmin(self::$currentIndex . '&token=' . Tools::getAdminTokenLite('AdminRedirect') . '&conf=4');
         }
     }
     parent::postProcess();
 }
开发者ID:acreno,项目名称:pm-ps,代码行数:62,代码来源:AdminRedirectController.php

示例5: getShopsIds

 public function getShopsIds()
 {
     $id_shops = array();
     if (Shop::getContext() == Shop::CONTEXT_ALL) {
         $shops = Shop::getShops();
         if (!empty($shops)) {
             foreach ($shops as $s) {
                 $id_shops[] = $s['id_shop'];
             }
         }
     } elseif (Shop::getContext() == Shop::CONTEXT_GROUP) {
         $shopid = Shop::getContextShopGroupID(true);
         $shops = ShopGroup::getShopsFromGroup($shopid);
         if (!empty($shops)) {
             foreach ($shops as $s) {
                 $id_shops[] = $s['id_shop'];
             }
         }
     }
     if (empty($id_shops)) {
         $id_shops[] = Shop::getContextShopID();
     }
     $id_shops = array_unique($id_shops);
     return $id_shops;
 }
开发者ID:acreno,项目名称:pm-ps,代码行数:25,代码来源:magicredirect.php

示例6: 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


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