本文整理汇总了PHP中ShopGroup::getIdByName方法的典型用法代码示例。如果您正苦于以下问题:PHP ShopGroup::getIdByName方法的具体用法?PHP ShopGroup::getIdByName怎么用?PHP ShopGroup::getIdByName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ShopGroup
的用法示例。
在下文中一共展示了ShopGroup::getIdByName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: supplierImportOne
protected function supplierImportOne($info, $shop_is_feature_active, $regenerate, $force_ids, $validateOnly = false)
{
AdminImportController::setDefaultValues($info);
if ($force_ids && isset($info['id']) && (int) $info['id']) {
$supplier = new Supplier((int) $info['id']);
} else {
if (array_key_exists('id', $info) && (int) $info['id'] && Supplier::existsInDatabase((int) $info['id'], 'supplier')) {
$supplier = new Supplier((int) $info['id']);
} else {
$supplier = new Supplier();
}
}
AdminImportController::arrayWalk($info, array('AdminImportController', 'fillInfo'), $supplier);
if (($field_error = $supplier->validateFields(UNFRIENDLY_ERROR, true)) === true && ($lang_field_error = $supplier->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true) {
$res = false;
if ($supplier->id && $supplier->supplierExists($supplier->id)) {
$res = $validateOnly || $supplier->update();
}
$supplier->force_id = (bool) $force_ids;
if (!$res) {
$res = $validateOnly || $supplier->add();
}
//copying images of suppliers
if (!$validateOnly && isset($supplier->image) && !empty($supplier->image)) {
if (!AdminImportController::copyImg($supplier->id, null, $supplier->image, 'suppliers', !$regenerate)) {
$this->warnings[] = $supplier->image . ' ' . $this->trans('cannot be copied.', array(), 'Admin.Parameters.Notification');
}
}
if (!$res) {
$this->errors[] = Db::getInstance()->getMsgError() . ' ' . sprintf($this->trans('%1$s (ID: %2$s) cannot be saved', array(), 'Admin.Parameters.Notification'), isset($info['name']) && !empty($info['name']) ? Tools::safeOutput($info['name']) : 'No Name', isset($info['id']) && !empty($info['id']) ? Tools::safeOutput($info['id']) : 'No ID');
} elseif (!$validateOnly) {
// Associate supplier to group shop
if ($shop_is_feature_active && $supplier->shop) {
Db::getInstance()->execute('
DELETE FROM ' . _DB_PREFIX_ . 'supplier_shop
WHERE id_supplier = ' . (int) $supplier->id);
$supplier->shop = explode($this->multiple_value_separator, $supplier->shop);
$shops = array();
foreach ($supplier->shop as $shop) {
if (empty($shop)) {
continue;
}
$shop = trim($shop);
if (!is_numeric($shop)) {
$shop = ShopGroup::getIdByName($shop);
}
$shops[] = $shop;
}
$supplier->associateTo($shops);
}
}
} else {
$this->errors[] = $this->l('Supplier is invalid') . ' (' . $supplier->name . ')';
$this->errors[] = ($field_error !== true ? $field_error : '') . (isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : '');
}
}
示例2: supplierImport
public function supplierImport()
{
$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 (Tools::getValue('forceIDs') && isset($info['id']) && (int) $info['id']) {
$supplier = new Supplier((int) $info['id']);
} else {
if (array_key_exists('id', $info) && (int) $info['id'] && Supplier::existsInDatabase((int) $info['id'], 'supplier')) {
$supplier = new Supplier((int) $info['id']);
} else {
$supplier = new Supplier();
}
}
AdminImportController::arrayWalk($info, array('AdminImportController', 'fillInfo'), $supplier);
if (($field_error = $supplier->validateFields(UNFRIENDLY_ERROR, true)) === true && ($lang_field_error = $supplier->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true) {
$res = false;
if ($supplier->id && $supplier->supplierExists($supplier->id)) {
$res = $supplier->update();
}
$supplier->force_id = (bool) Tools::getValue('forceIDs');
if (!$res) {
$res = $supplier->add();
}
//copying images of suppliers
if (isset($supplier->image) && !empty($supplier->image)) {
if (!AdminImportController::copyImg($supplier->id, null, $supplier->image, 'suppliers', !Tools::getValue('regenerate'))) {
$this->warnings[] = $supplier->image . ' ' . Tools::displayError('cannot be copied.');
}
}
if (!$res) {
$this->errors[] = Db::getInstance()->getMsgError() . ' ' . sprintf(Tools::displayError('%1$s (ID: %2$s) cannot be saved'), isset($info['name']) && !empty($info['name']) ? Tools::safeOutput($info['name']) : 'No Name', isset($info['id']) && !empty($info['id']) ? Tools::safeOutput($info['id']) : 'No ID');
} else {
// Associate supplier to group shop
if (Shop::isFeatureActive() && $supplier->shop) {
Db::getInstance()->execute('
DELETE FROM ' . _DB_PREFIX_ . 'supplier_shop
WHERE id_supplier = ' . (int) $supplier->id);
$supplier->shop = explode($this->multiple_value_separator, $supplier->shop);
$shops = array();
foreach ($supplier->shop as $shop) {
if (empty($shop)) {
continue;
}
$shop = trim($shop);
if (!is_numeric($shop)) {
$shop = ShopGroup::getIdByName($shop);
}
$shops[] = $shop;
}
$supplier->associateTo($shops);
}
}
} else {
$this->errors[] = $this->l('Supplier is invalid') . ' (' . $supplier->name . ')';
$this->errors[] = ($field_error !== true ? $field_error : '') . (isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : '');
}
}
$this->closeCsvFile($handle);
}