本文整理汇总了PHP中Shop::getShops方法的典型用法代码示例。如果您正苦于以下问题:PHP Shop::getShops方法的具体用法?PHP Shop::getShops怎么用?PHP Shop::getShops使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Shop
的用法示例。
在下文中一共展示了Shop::getShops方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: install
public function install()
{
if (!parent::install() || !$this->registerHook('displayHeader') || !$this->registerHook('displayAdditionalFooter')) {
return false;
}
$res = Db::getInstance()->execute('CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'footercontent` (
`id_content` int(10) unsigned NOT NULL auto_increment,
`id_shop` int(10) unsigned NOT NULL,
`width` int(10) unsigned NOT NULL,
PRIMARY KEY (`id_content`))
ENGINE=' . _MYSQL_ENGINE_ . ' DEFAULT CHARSET=utf8');
if ($res) {
$res &= Db::getInstance()->execute('CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'footercontent_lang` (
`id_content` int(10) unsigned NOT NULL,
`id_lang` int(10) unsigned NOT NULL,
`body_title` varchar(255) NOT NULL,
`body_paragraph` text NOT NULL,
PRIMARY KEY (`id_content`, `id_lang`))
ENGINE=' . _MYSQL_ENGINE_ . ' DEFAULT CHARSET=utf8');
}
if ($res) {
foreach (Shop::getShops(false) as $shop) {
$res &= $this->createExampleContent($shop['id_shop']);
}
}
if (!$res) {
$res &= $this->uninstall();
}
return (bool) $res;
}
示例2: initContent
/**
* Get view
*
* @return string
*/
public function initContent()
{
$options_time = array();
$time_slice = Configuration::get('APH_CALENDAR_TIME_SLICE');
for ($hours = 0; $hours < 24; $hours++) {
// the interval for hours is '1'
for ($mins = 0; $mins < 60; $mins += $time_slice) {
// the interval for mins is 'APH_CALENDAR_TIME_SLICE'
$options_time[str_pad($hours, 2, '0', STR_PAD_LEFT) . ':' . str_pad($mins, 2, '0', STR_PAD_LEFT)] = str_pad($hours, 2, '0', STR_PAD_LEFT) . ':' . str_pad($mins, 2, '0', STR_PAD_LEFT);
}
}
$this->context->smarty->assign('options_time', $options_time);
if ($this->display == 'edit') {
$obj = $this->loadObject(true);
$obj->from_time = substr($obj->from, 11, 5);
$obj->from = substr($obj->from, 0, 10);
$obj->to_time = substr($obj->to, 11, 5);
$obj->to = substr($obj->to, 0, 10);
$this->context->smarty->assign(array('obj' => $obj));
} elseif ($this->display == 'add') {
$this->context->smarty->assign(array('obj' => NULL));
}
if ($this->display == 'add' || $this->display == 'edit') {
$shops = Shop::getShops(true, null, false);
$languages = Language::getLanguages(true);
self::fetchEmployees();
$this->context->smarty->assign(array("id_lang_default" => Configuration::get('PS_LANG_DEFAULT'), 'tpl_dir' => $this->tpl_dir, "languages" => $languages, "shops" => $shops));
$this->content .= $this->context->smarty->fetch(_PS_MODULE_DIR_ . $this->module->name . "/views/templates/admin/controllers/availabilities/form.tpl");
}
parent::initContent();
}
示例3: renderForm
public function renderForm()
{
if (!$this->object->id) {
$this->object->price = -1;
}
$this->fields_form = array('legend' => array('title' => $this->trans('Catalog price rules', array(), 'Admin.Catalog.Feature'), 'icon' => 'icon-dollar'), 'input' => array(array('type' => 'text', 'label' => $this->trans('Name', array(), 'Admin.Global'), 'name' => 'name', 'maxlength' => 255, 'required' => true), array('type' => 'select', 'label' => $this->trans('Shop', array(), 'Admin.Global'), 'name' => 'shop_id', 'options' => array('query' => Shop::getShops(), 'id' => 'id_shop', 'name' => 'name'), 'condition' => Shop::isFeatureActive(), 'default_value' => Shop::getContextShopID()), array('type' => 'select', 'label' => $this->trans('Currency', array(), 'Admin.Global'), 'name' => 'id_currency', 'options' => array('query' => array_merge(array(0 => array('id_currency' => 0, 'name' => $this->trans('All currencies', array(), 'Admin.Global'))), Currency::getCurrencies(false, true, true)), 'id' => 'id_currency', 'name' => 'name')), array('type' => 'select', 'label' => $this->trans('Country', array(), 'Admin.Global'), 'name' => 'id_country', 'options' => array('query' => array_merge(array(0 => array('id_country' => 0, 'name' => $this->trans('All countries', array(), 'Admin.Global'))), Country::getCountries((int) $this->context->language->id)), 'id' => 'id_country', 'name' => 'name')), array('type' => 'select', 'label' => $this->trans('Group', array(), 'Admin.Global'), 'name' => 'id_group', 'options' => array('query' => array_merge(array(0 => array('id_group' => 0, 'name' => $this->trans('All groups', array(), 'Admin.Global'))), Group::getGroups((int) $this->context->language->id)), 'id' => 'id_group', 'name' => 'name')), array('type' => 'text', 'label' => $this->trans('From quantity', array(), 'Admin.Catalog.Feature'), 'name' => 'from_quantity', 'maxlength' => 10, 'required' => true), array('type' => 'text', 'label' => $this->trans('Price (tax excl.)', array(), 'Admin.Catalog.Feature'), 'name' => 'price', 'disabled' => $this->object->price == -1 ? 1 : 0, 'maxlength' => 10, 'suffix' => $this->context->currency->getSign('right')), array('type' => 'checkbox', 'name' => 'leave_bprice', 'values' => array('query' => array(array('id' => 'on', 'name' => $this->trans('Leave initial price', array(), 'Admin.Catalog.Feature'), 'val' => '1', 'checked' => '1')), 'id' => 'id', 'name' => 'name')), array('type' => 'datetime', 'label' => $this->trans('From', array(), 'Admin.Global'), 'name' => 'from'), array('type' => 'datetime', 'label' => $this->trans('To', array(), 'Admin.Global'), 'name' => 'to'), array('type' => 'select', 'label' => $this->trans('Reduction type', array(), 'Admin.Catalog.Feature'), 'name' => 'reduction_type', 'options' => array('query' => array(array('reduction_type' => 'amount', 'name' => $this->trans('Amount', array(), 'Admin.Global')), array('reduction_type' => 'percentage', 'name' => $this->trans('Percentage', array(), 'Admin.Global'))), 'id' => 'reduction_type', 'name' => 'name')), array('type' => 'select', 'label' => $this->trans('Reduction with or without taxes', array(), 'Admin.Catalog.Feature'), 'name' => 'reduction_tax', 'align' => 'center', 'options' => array('query' => array(array('lab' => $this->trans('Tax included', array(), 'Admin.Global'), 'val' => 1), array('lab' => $this->trans('Tax excluded', array(), 'Admin.Global'), 'val' => 0)), 'id' => 'val', 'name' => 'lab')), array('type' => 'text', 'label' => $this->trans('Reduction', array(), 'Admin.Catalog.Feature'), 'name' => 'reduction', 'required' => true)), 'submit' => array('title' => $this->trans('Save', array(), 'Admin.Actions')));
if (($value = $this->getFieldValue($this->object, 'price')) != -1) {
$price = number_format($value, 6);
} else {
$price = '';
}
$this->fields_value = array('price' => $price, 'from_quantity' => ($value = $this->getFieldValue($this->object, 'from_quantity')) ? $value : 1, 'reduction' => number_format(($value = $this->getFieldValue($this->object, 'reduction')) ? $value : 0, 6), 'leave_bprice_on' => $price ? 0 : 1, 'shop_id' => ($value = $this->getFieldValue($this->object, 'id_shop')) ? $value : 1);
$attribute_groups = array();
$attributes = Attribute::getAttributes((int) $this->context->language->id);
foreach ($attributes as $attribute) {
if (!isset($attribute_groups[$attribute['id_attribute_group']])) {
$attribute_groups[$attribute['id_attribute_group']] = array('id_attribute_group' => $attribute['id_attribute_group'], 'name' => $attribute['attribute_group']);
}
$attribute_groups[$attribute['id_attribute_group']]['attributes'][] = array('id_attribute' => $attribute['id_attribute'], 'name' => $attribute['name']);
}
$features = Feature::getFeatures((int) $this->context->language->id);
foreach ($features as &$feature) {
$feature['values'] = FeatureValue::getFeatureValuesWithLang((int) $this->context->language->id, $feature['id_feature'], true);
}
$this->tpl_form_vars = array('manufacturers' => Manufacturer::getManufacturers(), 'suppliers' => Supplier::getSuppliers(), 'attributes_group' => $attribute_groups, 'features' => $features, 'categories' => Category::getSimpleCategories((int) $this->context->language->id), 'conditions' => $this->object->getConditions(), 'is_multishop' => Shop::isFeatureActive());
return parent::renderForm();
}
示例4: renderForm
public function renderForm()
{
if (!$this->object->id) {
$this->object->price = -1;
}
$shops = Shop::getShops();
if (count($this->context->employee->getAssociatedShops()) > 1) {
$shops = array_merge(array(0 => array('id_shop' => 0, 'name' => $this->l('All shops'))), $shops);
}
$this->fields_form = array('legend' => array('title' => $this->l('Specific price rules')), 'input' => array(array('type' => 'text', 'label' => $this->l('Name:'), 'name' => 'name', 'size' => 33, 'maxlength' => 32, 'required' => true, 'hint' => $this->l('Forbidden characters:') . ' <>;=#{}'), array('type' => 'select', 'label' => $this->l('Shop:'), 'name' => 'id_shop', 'options' => array('query' => $shops, 'id' => 'id_shop', 'name' => 'name'), 'condition' => Shop::isFeatureActive(), 'default_value' => Shop::getContextShopID()), array('type' => 'select', 'label' => $this->l('Currency:'), 'name' => 'id_currency', 'options' => array('query' => array_merge(array(0 => array('id_currency' => 0, 'name' => $this->l('All currencies'))), Currency::getCurrencies()), 'id' => 'id_currency', 'name' => 'name')), array('type' => 'select', 'label' => $this->l('Country:'), 'name' => 'id_country', 'options' => array('query' => array_merge(array(0 => array('id_country' => 0, 'name' => $this->l('All countries'))), Country::getCountries((int) $this->context->language->id)), 'id' => 'id_country', 'name' => 'name')), array('type' => 'select', 'label' => $this->l('Group:'), 'name' => 'id_group', 'options' => array('query' => array_merge(array(0 => array('id_group' => 0, 'name' => $this->l('All groups'))), Group::getGroups((int) $this->context->language->id)), 'id' => 'id_group', 'name' => 'name')), array('type' => 'text', 'label' => $this->l('From quantity:'), 'name' => 'from_quantity', 'size' => 6, 'maxlength' => 10, 'required' => true), array('type' => 'text', 'label' => $this->l('Price (tax excl.):'), 'name' => 'price', 'size' => 6, 'disabled' => $this->object->price == -1 ? 1 : 0, 'maxlength' => 10, 'suffix' => $this->context->currency->getSign('right')), array('type' => 'checkbox', 'name' => 'leave_bprice', 'values' => array('query' => array(array('id' => 'on', 'name' => $this->l('Leave base price'), 'val' => '1', 'checked' => '1')), 'id' => 'id', 'name' => 'name')), array('type' => 'date', 'label' => $this->l('From:'), 'name' => 'from', 'size' => 12), array('type' => 'date', 'label' => $this->l('To:'), 'name' => 'to', 'size' => 12), array('type' => 'select', 'label' => $this->l('Reduction type:'), 'name' => 'reduction_type', 'options' => array('query' => array(array('reduction_type' => 'amount', 'name' => $this->l('Amount')), array('reduction_type' => 'percentage', 'name' => $this->l('Percentage'))), 'id' => 'reduction_type', 'name' => 'name')), array('type' => 'text', 'label' => $this->l('Reduction:'), 'name' => 'reduction', 'required' => true)), 'submit' => array('title' => $this->l('Save'), 'class' => 'button'));
if (($value = $this->getFieldValue($this->object, 'price')) != -1) {
$price = number_format($value, 2);
} else {
$price = '';
}
$this->fields_value = array('price' => $price, 'from_quantity' => ($value = $this->getFieldValue($this->object, 'from_quantity')) ? $value : 1, 'reduction' => number_format(($value = $this->getFieldValue($this->object, 'reduction')) ? $value : 0, 2), 'leave_bprice_on' => $price ? 0 : 1);
$attribute_groups = array();
$attributes = Attribute::getAttributes((int) $this->context->language->id);
foreach ($attributes as $attribute) {
if (!isset($attribute_groups[$attribute['id_attribute_group']])) {
$attribute_groups[$attribute['id_attribute_group']] = array('id_attribute_group' => $attribute['id_attribute_group'], 'name' => $attribute['attribute_group']);
}
$attribute_groups[$attribute['id_attribute_group']]['attributes'][] = array('id_attribute' => $attribute['id_attribute'], 'name' => $attribute['name']);
}
$features = Feature::getFeatures((int) $this->context->language->id);
foreach ($features as &$feature) {
$feature['values'] = FeatureValue::getFeatureValuesWithLang((int) $this->context->language->id, $feature['id_feature'], true);
}
$this->tpl_form_vars = array('manufacturers' => Manufacturer::getManufacturers(), 'suppliers' => Supplier::getSuppliers(), 'attributes_group' => $attribute_groups, 'features' => $features, 'categories' => Category::getSimpleCategories((int) $this->context->language->id), 'conditions' => $this->object->getConditions(), 'is_multishop' => Shop::isFeatureActive());
return parent::renderForm();
}
示例5: install
public function install()
{
if (!parent::install() || !$this->registerHook('leftColumn') || !$this->registerHook('rightColumn') || !$this->registerHook('header') || !$this->registerHook('footer') || !$this->registerHook('actionObjectCmsUpdateAfter') || !$this->registerHook('actionObjectCmsDeleteAfter') || !$this->registerHook('actionShopDataDuplication') || !$this->registerHook('actionAdminStoresControllerUpdate_optionsAfter') || !BlockCMSModel::createTables() || !Configuration::updateValue('FOOTER_CMS', '') || !Configuration::updateValue('FOOTER_BLOCK_ACTIVATION', 1) || !Configuration::updateValue('FOOTER_POWEREDBY', 1) || !Configuration::updateValue('FOOTER_PRICE-DROP', 1) || !Configuration::updateValue('FOOTER_NEW-PRODUCTS', 1) || !Configuration::updateValue('FOOTER_BEST-SALES', 1) || !Configuration::updateValue('FOOTER_CONTACT', 1) || !Configuration::updateValue('FOOTER_SITEMAP', 1)) {
return false;
}
$this->_clearCache('blockcms.tpl');
// Install fixtures for blockcms
$default = Db::getInstance()->insert('cms_block', array('id_cms_category' => 1, 'location' => 0, 'position' => 0));
if (!$default) {
return false;
}
$result = true;
$id_cms_block = Db::getInstance()->Insert_ID();
$shops = Shop::getShops(true, null, true);
foreach ($shops as $shop) {
$result &= Db::getInstance()->insert('cms_block_shop', array('id_cms_block' => $id_cms_block, 'id_shop' => $shop));
}
$languages = Language::getLanguages(false);
foreach ($languages as $lang) {
$result &= Db::getInstance()->insert('cms_block_lang', array('id_cms_block' => $id_cms_block, 'id_lang' => $lang['id_lang'], 'name' => $this->l('Information')));
}
$pages = CMS::getCMSPages(null, 1);
foreach ($pages as $cms) {
$result &= Db::getInstance()->insert('cms_block_page', array('id_cms_block' => $id_cms_block, 'id_cms' => $cms['id_cms'], 'is_category' => 0));
}
return $result;
}
示例6: install
public function install()
{
if (!parent::install() || !$this->registerHooks() || !BlockCMSModel::createTables() || !Configuration::updateValue('FOOTER_CMS', '') || !Configuration::updateValue('FOOTER_BLOCK_ACTIVATION', 1) || !Configuration::updateValue('FOOTER_POWEREDBY', 1)) {
return false;
}
// Install fixtures for blockcms
$default = Db::getInstance()->insert('cms_block', array('id_cms_category' => 1, 'location' => 0, 'position' => 0));
if (!$default) {
return false;
}
$result = true;
$id_cms_block = Db::getInstance()->Insert_ID();
$shops = Shop::getShops(true, null, true);
foreach ($shops as $shop) {
$result &= Db::getInstance()->insert('cms_block_shop', array('id_cms_block' => $id_cms_block, 'id_shop' => $shop));
}
$languages = Language::getLanguages(false);
foreach ($languages as $lang) {
$result &= Db::getInstance()->insert('cms_block_lang', array('id_cms_block' => $id_cms_block, 'id_lang' => $lang['id_lang'], 'name' => $this->l('Information')));
}
$pages = CMS::getCMSPages(null, 1);
foreach ($pages as $cms) {
$result &= Db::getInstance()->insert('cms_block_page', array('id_cms_block' => $id_cms_block, 'id_cms' => $cms['id_cms'], 'is_category' => 0));
}
return $result;
}
示例7: install
public function install()
{
if (!parent::install() || !$this->registerHook('displayNav') || !$this->registerHook('freeFblock') || !$this->registerHook('displayHeader')) {
return false;
}
$res = Db::getInstance()->execute('
CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'slidetopcontent` (
`id_slidetopcontent` int(10) unsigned NOT NULL auto_increment,
`id_shop` int(10) unsigned NOT NULL ,
PRIMARY KEY (`id_slidetopcontent`))
ENGINE=' . _MYSQL_ENGINE_ . ' DEFAULT CHARSET=utf8');
if ($res) {
$res &= Db::getInstance()->execute('
CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'slidetopcontent_lang` (
`id_slidetopcontent` int(10) unsigned NOT NULL,
`id_lang` int(10) unsigned NOT NULL,
`main_title` varchar(255) NOT NULL,
`main_paragraph` text NOT NULL,
`main_link` varchar(255) NOT NULL,
`second_title` varchar(255) NOT NULL,
`second_paragraph` text NOT NULL,
`second_link` varchar(255) NOT NULL,
PRIMARY KEY (`id_slidetopcontent`, `id_lang`))
ENGINE=' . _MYSQL_ENGINE_ . ' DEFAULT CHARSET=utf8');
}
if ($res) {
foreach (Shop::getShops(false) as $shop) {
$res &= $this->createExample($shop['id_shop']);
}
}
if (!$res) {
$res &= $this->uninstall();
}
return $res;
}
示例8: list_shops
public static function list_shops()
{
$shops = Shop::getShops(false);
$table = new Cli\Table();
$table->setHeaders(array('id', 'group', 'name', 'theme', 'category', 'domain', 'domain_ssl', 'uri', 'active'));
foreach ($shops as $shop) {
$theme = new Theme($shop['id_theme']);
if (Validate::isLoadedObject($theme)) {
$themeName = $theme->name;
} else {
$themeName = $shop['id_theme'];
}
unset($theme);
$group = new ShopGroup($shop['id_shop_group']);
if (Validate::isLoadedObject($group)) {
$groupName = $group->name;
} else {
$groupName = $shop['id_shop_group'];
}
unset($group);
$category = new Category($shop['id_category']);
if (Validate::isLoadedObject($category)) {
$categoryName = array_pop($category->name);
} else {
$categoryName = $shop['id_category'];
}
unset($category);
$table->addRow(array($shop['id_shop'], $groupName, $shop['name'], $themeName, $categoryName, $shop['domain'], $shop['domain_ssl'], $shop['uri'], $shop['active']));
}
$table->display();
}
示例9: renderForm
public function renderForm()
{
$update_htaccess = Tools::modRewriteActive() && (file_exists('.htaccess') && is_writable('.htaccess') || is_writable(dirname('.htaccess')));
$this->multiple_fieldsets = true;
if (!$update_htaccess) {
$desc_virtual_uri = array('<span class="warning_mod_rewrite">' . $this->l('You need to activate URL Rewriting if you want to add a virtual URL.') . '</span>');
} else {
$desc_virtual_uri = array($this->l('You can use this option if you want to create a store with a URL that doesn\'t exist on your server (e.g. if you want your store to be available with the URL www.my-prestashop.com/my-store/shoes/, you have to set shoes/ in this field, assuming that my-store/ is your Physical URL).'), '<strong>' . $this->l('URL rewriting must be activated on your server to use this feature.') . '</strong>');
}
$this->fields_form = array(array('form' => array('legend' => array('title' => $this->l('URL options'), 'icon' => 'icon-cogs'), 'input' => array(array('type' => 'select', 'label' => $this->l('Shop'), 'name' => 'id_shop', 'onchange' => 'checkMainUrlInfo(this.value);', 'options' => array('optiongroup' => array('query' => Shop::getTree(), 'label' => 'name'), 'options' => array('query' => 'shops', 'id' => 'id_shop', 'name' => 'name'))), array('type' => 'switch', 'label' => $this->l('Main URL'), 'name' => 'main', 'class' => 't', 'values' => array(array('id' => 'main_on', 'value' => 1), array('id' => 'main_off', 'value' => 0)), 'desc' => array($this->l('If you set this URL as the Main URL for the selected shop, all URLs set to this shop will be redirected to this URL (you can only have one Main URL per shop).'), array('text' => $this->l('Since the selected shop has no main URL, you have to set this URL as the Main URL.'), 'id' => 'mainUrlInfo'), array('text' => $this->l('The selected shop already has a Main URL. Therefore, if you set this one as the Main URL, the older of the two will be set as the normal URL.'), 'id' => 'mainUrlInfoExplain'))), array('type' => 'switch', 'label' => $this->l('Enabled'), 'name' => 'active', 'required' => false, 'class' => 't', 'values' => array(array('id' => 'active_on', 'value' => 1), array('id' => 'active_off', 'value' => 0)))), 'submit' => array('title' => $this->l('Save')))), array('form' => array('legend' => array('title' => $this->l('Shop URL'), 'icon' => 'icon-shopping-cart'), 'input' => array(array('type' => 'text', 'label' => $this->l('Domain'), 'name' => 'domain', 'size' => 50), array('type' => 'text', 'label' => $this->l('Domain SSL'), 'name' => 'domain_ssl', 'size' => 50)), 'submit' => array('title' => $this->l('Save')))));
if (!defined('_PS_HOST_MODE_')) {
$this->fields_form[1]['form']['input'] = array_merge($this->fields_form[1]['form']['input'], array(array('type' => 'text', 'label' => $this->l('Physical URL'), 'name' => 'physical_uri', 'desc' => $this->l('This is the physical folder for your store on the server. Leave this field empty if your store is installed on the root path (e.g. if your store is available at www.my-prestashop.com/my-store/, you input my-store/ in this field).'), 'size' => 50)));
}
$this->fields_form[1]['form']['input'] = array_merge($this->fields_form[1]['form']['input'], array(array('type' => 'text', 'label' => $this->l('Virtual URL'), 'name' => 'virtual_uri', 'desc' => $desc_virtual_uri, 'size' => 50, 'hint' => !$update_htaccess ? $this->l('Warning: URL rewriting (e.g. mod_rewrite for Apache) seems to be disabled. If your URL doesn\'t work, please check with your host provider on how to activate URL rewriting.') : null), array('type' => 'text', 'label' => $this->l('Your final URL will be'), 'name' => 'final_url', 'size' => 76, 'readonly' => true)));
if (!($obj = $this->loadObject(true))) {
return;
}
self::$currentIndex = self::$currentIndex . '&id_shop=' . $obj->id;
$current_shop = Shop::initialize();
$list_shop_with_url = array();
foreach (Shop::getShops(false, null, true) as $id) {
$list_shop_with_url[$id] = (bool) count(ShopUrl::getShopUrls($id));
}
$this->tpl_form_vars = array('js_shop_url' => Tools::jsonEncode($list_shop_with_url));
$this->fields_value = array('domain' => Validate::isLoadedObject($obj) ? $this->getFieldValue($obj, 'domain') : $current_shop->domain, 'domain_ssl' => Validate::isLoadedObject($obj) ? $this->getFieldValue($obj, 'domain_ssl') : $current_shop->domain_ssl, 'physical_uri' => Validate::isLoadedObject($obj) ? $this->getFieldValue($obj, 'physical_uri') : $current_shop->physical_uri, 'active' => true);
return parent::renderForm();
}
示例10: updateImageInPrestashop
/**
* Updates product image in Prestashop.
*
* @param integer $id_product, integer $id_img, string $url, string $name_photo
* @return integer
* @see $this->copyImg
*
*/
public function updateImageInPrestashop($id_product, $id_img, $url, $name_photo)
{
if (empty($id_img)) {
return (int) $this->insertImageInPrestashop($id_product, $url, $name_photo);
} else {
$shops = Shop::getShops(true, null, true);
$image = new ImageCore((int) $id_img);
$image->id_product = $id_product;
$tmp = explode(".", $name_photo);
$name_photo_product = "";
$name_for_legend = "";
if (count($tmp) == 1) {
$name_photo_product = trim($url) . $name_photo . ".jpg";
$name_for_legend = $name_photo . ".jpg";
} else {
$name_photo_product = trim($url) . $name_photo;
$name_for_legend = $name_photo;
}
$image->legend = array('1' => trim($name_for_legend));
if ($image->validateFields(false, true) === true && $image->validateFieldsLang(false, true) === true && $image->update()) {
$image->associateTo($shops);
if (!$this->copyImg($id_product, $id_img, $name_photo_product, 'products')) {
$image->delete();
}
}
return (int) $image->id;
}
}
示例11: install
public function install()
{
if (!parent::install() || !$this->registerHook('displayHome') || !$this->registerHook('displayHeader')) {
return false;
}
$res = Db::getInstance()->execute('
CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'editorial` (
`id_editorial` int(10) unsigned NOT NULL auto_increment,
`id_shop` int(10) unsigned NOT NULL ,
`body_home_logo_link` varchar(255) NOT NULL,
PRIMARY KEY (`id_editorial`))
ENGINE=' . _MYSQL_ENGINE_ . ' DEFAULT CHARSET=utf8');
if ($res) {
$res &= Db::getInstance()->execute('
CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'editorial_lang` (
`id_editorial` int(10) unsigned NOT NULL,
`id_lang` int(10) unsigned NOT NULL,
`body_title` varchar(255) NOT NULL,
`body_subheading` varchar(255) NOT NULL,
`body_paragraph` text NOT NULL,
`body_logo_subheading` varchar(255) NOT NULL,
PRIMARY KEY (`id_editorial`, `id_lang`))
ENGINE=' . _MYSQL_ENGINE_ . ' DEFAULT CHARSET=utf8');
}
if ($res) {
foreach (Shop::getShops(false) as $shop) {
$res &= $this->createExampleEditorial($shop['id_shop']);
}
}
if (!$res) {
$res &= $this->uninstall();
}
return $res;
}
示例12: getSites
/**
* Get all site information - both Jirafe specific and general
* @return array $sites An array of site information as per Jirafe API spec
*/
public function getSites()
{
$sites = array();
// First, get the general site info from the Prestashop database
Shop::cacheShops(true);
// we must refresh cache to get last insertion
$psShops = Shop::getShops();
// Get the Jirafe specific information about Prestashop sites
$jsites = unserialize(base64_decode($this->get('sites')));
if (!empty($psShops)) {
foreach ($psShops as $psShop) {
if ($psShop['active']) {
$shopId = $psShop['id_shop'];
$site = array();
$site['external_id'] = $shopId;
$site['description'] = $psShop['name'];
$site['url'] = 'http://' . $psShop['domain'] . $psShop['uri'];
$site['timezone'] = Configuration::get('PS_TIMEZONE');
$site['currency'] = $this->_getCurrency($shopId);
if (!empty($jsites[$shopId])) {
$site += $jsites[$shopId];
}
// new sites in prestashop are created without url
// api require a valid unique url
if ($site['url'] === 'http://') {
$site['url'] = 'http://example.' . md5(time() + $site['external_id']) . '.com';
}
// Add the site to the list of sites to return
$sites[] = $site;
}
}
}
return $sites;
}
示例13: uninstall
public function uninstall()
{
$shops = Shop::getShops(false);
foreach ($shops as $shop) {
$file = dirname(__FILE__) . '/img/' . $shop['id_shop'] . scrolltop::USER_IMG;
if (file_exists($file)) {
unlink($file);
}
}
return parent::uninstall() and $this->unregisterHook('footer');
}
示例14: init
public function init()
{
parent::init();
// context->shop is set in the init() function, so we move the _category instanciation after that
if (($id_category = Tools::getvalue('id_category')) && $this->action != 'select_delete') {
$this->_category = new Category($id_category);
} else {
if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) {
$this->_category = new Category($this->context->shop->id_category);
} elseif (count(Category::getCategoriesWithoutParent()) > 1 && Configuration::get('PS_MULTISHOP_FEATURE_ACTIVE') && count(Shop::getShops(true, null, true)) != 1) {
$this->_category = Category::getTopCategory();
} else {
$this->_category = new Category(Configuration::get('PS_HOME_CATEGORY'));
}
}
$count_categories_without_parent = count(Category::getCategoriesWithoutParent());
$top_category = Category::getTopCategory();
if (Tools::isSubmit('id_category')) {
$id_parent = $this->_category->id;
} elseif (!Shop::isFeatureActive() && $count_categories_without_parent > 1) {
$id_parent = $top_category->id;
} elseif (Shop::isFeatureActive() && $count_categories_without_parent == 1) {
$id_parent = Configuration::get('PS_HOME_CATEGORY');
} elseif (Shop::isFeatureActive() && $count_categories_without_parent > 1 && Shop::getContext() != Shop::CONTEXT_SHOP) {
if (Configuration::get('PS_MULTISHOP_FEATURE_ACTIVE') && count(Shop::getShops(true, null, true)) == 1) {
$id_parent = $this->context->shop->id_category;
} else {
$id_parent = $top_category->id;
}
} else {
$id_parent = $this->context->shop->id_category;
}
$this->_select = 'sa.position position';
$this->_filter .= ' AND `id_parent` = ' . (int) $id_parent . ' ';
if (Shop::getContext() == Shop::CONTEXT_SHOP) {
$this->_join .= ' LEFT JOIN `' . _DB_PREFIX_ . 'category_shop` sa ON (a.`id_category` = sa.`id_category` AND sa.id_shop = ' . (int) $this->context->shop->id . ') ';
} else {
$this->_join .= ' LEFT JOIN `' . _DB_PREFIX_ . 'category_shop` sa ON (a.`id_category` = sa.`id_category` AND sa.id_shop = a.id_shop_default) ';
}
// we add restriction for shop
if (Shop::getContext() == Shop::CONTEXT_SHOP && Shop::isFeatureActive()) {
$this->_where = ' AND sa.`id_shop` = ' . (int) Context::getContext()->shop->id;
}
// if we are not in a shop context, we remove the position column
if (Shop::isFeatureActive() && Shop::getContext() != Shop::CONTEXT_SHOP) {
unset($this->fields_list['position']);
}
// shop restriction : if category is not available for current shop, we redirect to the list from default category
if (!$this->_category->isAssociatedToShop() && Shop::getContext() == Shop::CONTEXT_SHOP) {
$this->redirect_after = self::$currentIndex . '&id_category=' . (int) $this->context->shop->getCategory() . '&token=' . $this->token;
$this->redirect();
}
}
示例15: addRadioCurrencyRestrictionsForModule
/**
* Add radio currency restrictions for a new module
* @param array $shops
*
* @return bool
*/
public function addRadioCurrencyRestrictionsForModule(array $shops = array())
{
if (!$shops) {
$shops = Shop::getShops(true, null, true);
}
foreach ($shops as $s) {
if (!Db::getInstance()->execute('INSERT INTO `' . _DB_PREFIX_ . 'module_currency` (`id_module`, `id_shop`, `id_currency`)
VALUES (' . (int) $this->id . ', "' . (int) $s . '", -2)')) {
return false;
}
}
return true;
}