public function init()
    {
        if (Tools::getValue('supplier_rewrite')) {
            $name_supplier = str_replace('-', '%', Tools::getValue('supplier_rewrite'));
            //
            // TODO:: need to core update Prestashop code and
            // DB for link_rewrite for suppliers
            // Should we use the Mysql FullText Index Search ??
            //
            $sql = 'SELECT sp.`id_supplier`
				FROM `' . _DB_PREFIX_ . 'supplier` sp
				LEFT JOIN `' . _DB_PREFIX_ . 'supplier_shop` s ON (sp.`id_supplier` = s.`id_supplier`)
				WHERE sp.`name` LIKE \'' . $name_supplier . '\'';
            if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) {
                $sql .= ' AND s.`id_shop` = ' . (int) Shop::getContextShopID();
            }
            $id_supplier = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql);
            if ($id_supplier > 0) {
                $_GET['id_supplier'] = $id_supplier;
            } else {
                //TODO: Do we need to send 404?
                header('HTTP/1.1 404 Not Found');
                header('Status: 404 Not Found');
            }
        }
        parent::init();
    }
Ejemplo n.º 2
0
 /**
  * Assign template vars related to page content
  * @see FrontController::initContent()
  */
 public function initContent()
 {
     parent::initContent();
     $this->addJS(_THEME_JS_DIR_ . 'index.js');
     $this->addJS(_THEME_JS_DIR_ . 'modernizr.custom.js');
     $this->addJS(_THEME_JS_DIR_ . 'toucheffects.js');
     $this->addJS(_THEME_JS_DIR_ . 'supplier_list.js');
     $this->addJS(_THEME_JS_DIR_ . 'jquery.bxslider.js');
     $this->addJS(_THEME_JS_DIR_ . 'header.js');
     $this->addJS(_THEME_JS_DIR_ . 'waypoints.min.js');
     $this->addJS(_THEME_JS_DIR_ . 'jquery.counterup.min.js');
     $this->addJS(_THEME_JS_DIR_ . 'front.js');
     $supplier = new SupplierControllerCore();
     if ($idCategory == null) {
         $supplier->initContent($this->idCategory);
     } else {
         $supplier->initContent($this->idCategory);
     }
     /**
      * get categories level 2 for present them in header
      **/
     $categories = Category::getChildrenWithNbSelectedSubCat(2, '', true, null, true);
     $this->context->smarty->assign(array('categories' => $categories));
     $this->assignKPI();
     /*$this->context->smarty->assign(array('HOOK_HOME' => Hook::exec('displayHome'),
           'HOOK_HOME_TAB' => Hook::exec('displayHomeTab'),
           'HOOK_HOME_TAB_CONTENT' => Hook::exec('displayHomeTabContent')
       ));*/
     $this->setTemplate(_PS_THEME_DIR_ . 'index.tpl');
 }
Ejemplo n.º 3
0
 public function init()
 {
     if ($supplier_rewrite = Tools::getValue('supplier_rewrite')) {
         $sql = 'SELECT sp.`id_supplier`
             FROM `' . _DB_PREFIX_ . 'supplier` sp
             LEFT JOIN `' . _DB_PREFIX_ . 'supplier_shop` s ON (sp.`id_supplier` = s.`id_supplier`)
             WHERE sp.`name` LIKE \'' . pSQL(str_replace('-', '%', $supplier_rewrite)) . '\'';
         if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) {
             $sql .= ' AND s.`id_shop` = ' . (int) Shop::getContextShopID();
         }
         $id_supplier = (int) Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql);
         if ($id_supplier > 0) {
             $_GET['id_supplier'] = $id_supplier;
         }
     }
     parent::init();
 }
Ejemplo n.º 4
0
    public function init()
    {
        if (Tools::getValue('supplier_rewrite')) {
            $name_supplier = str_replace('-', '%', Tools::getValue('supplier_rewrite'));
            $id_supplier = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
				SELECT `id_supplier`
				FROM `' . _DB_PREFIX_ . 'supplier`
				WHERE `name` LIKE \'' . $name_supplier . '\'');
            if ($id_supplier > 0) {
                $_GET['id_supplier'] = $id_supplier;
                $_GET['noredirect'] = 1;
            } else {
                Tools::display404Error();
                die;
            }
        }
        parent::init();
    }
    /**
     * Method init() : Initialize supplier controller with supplier_rewrite params
     *
     * @module now_seo_links
     *
     * @see SupplierControllerCore::init()
     */
    public function init()
    {
        // Get rewrite
        $sRewrite = str_replace('-', '%', Tools::getValue('supplier_rewrite', false));
        if ($sRewrite) {
            $iIdSupplier = (int) Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
				SELECT `id_supplier`
				FROM `' . _DB_PREFIX_ . 'supplier`
				WHERE `name` LIKE \'' . $sRewrite . '\'
			');
            if ($iIdSupplier) {
                $_GET['id_supplier'] = $iIdSupplier;
            }
        }
        parent::init();
        // On vérifie si l'URL actuelle est correcte ou pas
        $goodUrl = Context::getContext()->link->getSupplierLink($this->supplier);
        if (!preg_match('#' . $_SERVER['REDIRECT_URL'] . '#', $goodUrl)) {
            header('Status: 301 Moved Permanently', false, 301);
            header('Location: ' . $goodUrl);
            exit;
        }
    }