[-] MO: Blocktopmenu add links to shop

This commit is contained in:
rGaillard committed 2012-06-20 15:38:08 +00:00
1 parent bbf3f2d301
commit b09db02ac9
2 files changed
+37 -6

No files matched your search

+7 -1
View File
@@ -165,6 +165,10 @@ class ShopCore extends ObjectModel
{ {
parent::__construct($id, $id_lang, $id_shop); parent::__construct($id, $id_lang, $id_shop);
if ($this->id) if ($this->id)
$this->setUrl();
}
public function setUrl()
{ {
$sql = 'SELECT su.physical_uri, su.virtual_uri, $sql = 'SELECT su.physical_uri, su.virtual_uri,
su.domain, su.domain_ssl, t.id_theme, t.name, t.directory su.domain, su.domain_ssl, t.id_theme, t.name, t.directory
@@ -175,6 +179,7 @@ class ShopCore extends ObjectModel
AND s.active = 1 AND s.active = 1
AND s.deleted = 0 AND s.deleted = 0
AND su.main = 1'; AND su.main = 1';
if (!$row = Db::getInstance()->getRow($sql)) if (!$row = Db::getInstance()->getRow($sql))
return; return;
@@ -185,7 +190,8 @@ class ShopCore extends ObjectModel
$this->virtual_uri = $row['virtual_uri']; $this->virtual_uri = $row['virtual_uri'];
$this->domain = $row['domain']; $this->domain = $row['domain'];
$this->domain_ssl = $row['domain_ssl']; $this->domain_ssl = $row['domain_ssl'];
}
return true;
} }
/** /**
+30 -5
View File
@@ -243,6 +243,20 @@ class Blocktopmenu extends Module
$this->getCategoryOption(1, (int)$id_lang, (int)Shop::getContextShopID()); $this->getCategoryOption(1, (int)$id_lang, (int)Shop::getContextShopID());
$this->_html .= '</optgroup>'; $this->_html .= '</optgroup>';
// BEGIN Shops
if (Shop::isFeatureActive())
{
$this->_html .= '<optgroup label="'.$this->l('Shops').'">';
$shops = Shop::getShopsCollection();
foreach ($shops as $shop)
{
if (!$shop->setUrl() && !$shop->getBaseURL())
continue;
$this->_html .= '<option value="SHOP'.(int)$shop->id.'">'.$spacer.$shop->name.'</option>';
}
$this->_html .= '</optgroup>';
}
// BEGIN Products // BEGIN Products
$this->_html .= '<optgroup label="'.$this->l('Products').'">'; $this->_html .= '<optgroup label="'.$this->l('Products').'">';
$this->_html .= '<option value="PRODUCT" style="font-style:italic">'.$spacer.$this->l('Choose ID product').'</option>'; $this->_html .= '<option value="PRODUCT" style="font-style:italic">'.$spacer.$this->l('Choose ID product').'</option>';
@@ -422,7 +436,6 @@ class Blocktopmenu extends Module
$menu_item = $this->getMenuItems(); $menu_item = $this->getMenuItems();
$id_lang = (int)$this->context->language->id; $id_lang = (int)$this->context->language->id;
$id_shop = (int)Shop::getContextShopID(); $id_shop = (int)Shop::getContextShopID();
foreach ($menu_item as $item) foreach ($menu_item as $item)
{ {
if (!$item) if (!$item)
@@ -481,14 +494,17 @@ class Blocktopmenu extends Module
$this->_html .= '<option value="LNK'.$link[0]['id_linksmenutop'].'">'.$link[0]['label'].'</option>'; $this->_html .= '<option value="LNK'.$link[0]['id_linksmenutop'].'">'.$link[0]['label'].'</option>';
} }
break; break;
case 'SHOP':
$shop = new Shop((int)$id);
if (Validate::isLoadedObject($shop))
$this->_html .= '<option value="SHOP'.(int)$id.'">'.$shop->name.'</option>'.PHP_EOL;
break;
} }
} }
} }
private function makeMenu() private function makeMenu()
{ {
$this->page_name = Dispatcher::getInstance()->getController();
$menu_items = $this->getMenuItems(); $menu_items = $this->getMenuItems();
$id_lang = (int)$this->context->language->id; $id_lang = (int)$this->context->language->id;
$id_shop = (int)Shop::getContextShopID(); $id_shop = (int)Shop::getContextShopID();
@@ -555,6 +571,15 @@ class Blocktopmenu extends Module
} }
break; break;
case 'SHOP':
$selected = ($this->page_name == 'index' && (Tools::getValue('id_shop') == $id)) ? ' class="sfHover"' : '';
$shop = new Shop((int)$id);
if (Validate::isLoadedObject($shop))
{
$link = new Link;
$this->_menu .= '<li'.$selected.'><a href="'.$shop->getBaseURL().'">'.$shop->name.'</a></li>'.PHP_EOL;
}
break;
case 'LNK': case 'LNK':
$link = MenuTopLinks::get((int)$id, (int)$id_lang, (int)$id_shop); $link = MenuTopLinks::get((int)$id, (int)$id_lang, (int)$id_shop);
if (count($link)) if (count($link))
@@ -690,8 +715,8 @@ class Blocktopmenu extends Module
public function hookTop($param) public function hookTop($param)
{ {
$this->user_groups = ($this->context->customer->isLogged() ? $this->context->customer->getGroups() : array(Configuration::get('PS_UNIDENTIFIED_GROUP'))); $this->user_groups = ($this->context->customer->isLogged() ? $this->context->customer->getGroups() : array(Configuration::get('PS_UNIDENTIFIED_GROUP')));
$smarty_cache_id = 'blocktopmenu-'.(int)$this->context->shop->id.'-'.implode(', ',$this->user_groups).'-'.(int)$this->context->language->id.'-'.(int)Tools::getValue('id_category').'-'.(int)Tools::getValue('id_manufacturer').'-'.(int)Tools::getValue('id_supplier').'-'.(int)Tools::getValue('id_cms').'-'.(int)Tools::getValue('id_product'); $this->page_name = Dispatcher::getInstance()->getController();
$smarty_cache_id = 'blocktopmenu-'.$this->page_name.'-'.(int)$this->context->shop->id.'-'.implode(', ',$this->user_groups).'-'.(int)$this->context->language->id.'-'.(int)Tools::getValue('id_category').'-'.(int)Tools::getValue('id_manufacturer').'-'.(int)Tools::getValue('id_supplier').'-'.(int)Tools::getValue('id_cms').'-'.(int)Tools::getValue('id_product');
Tools::enableCache(); Tools::enableCache();
if (!$this->isCached('blocktopmenu.tpl', $smarty_cache_id)) if (!$this->isCached('blocktopmenu.tpl', $smarty_cache_id))
{ {