Product page as homepage in Opencart

百般思念 提交于 2019-12-06 07:47:25

Both of these require you to edit your /catalog/controller/common/home.php and place the code after the public function index() { line, changing 123 to your products id

v1.5.x

$this->redirect($this->url->link('product/product', 'product_id=123'));

v2.x + v3.x

$this->response->redirect($this->url->link('product/product', 'product_id=123'));

If you want to show the homepage URL and display the product you can edit the /index.php file and add the following code

if (!isset($request->get['route']) || $request->get['route'] == 'common/home')   {
    $request->get['route'] = 'product/product';
    $request->get['product_id'] = 1;
}

Add it below the code

// SEO URL's
$controller->addPreAction(new Action('common/seo_url'));

You will need to change the product_id to the id of your product. e.g. $request->get['product_id'] = 12;

In the case of redirect the particular product page as home page is pretty good but you need to change the redirection URL while you are changing the product...

It is simple ->>>>>>>> $this->redirect($this->url->link('product/product', 'product_id=123'));

But just use featured Category in your home page...

Module->Featured->Limit & enable..

Product->edit(particular product)->special->leave price field and fix start date and end date...

System->design->layout->home->edit->add featured module in content top set priority 1

OpenCart 2.3

file catalog/controller/startup/seo_url.php after

// Add rewrite to url class
        if ($this->config->get('config_seo_url')) {
            $this->url->addRewrite($this);
        }

insert

if ( !isset($this->request->get['_route_']) && !isset($this->request->get['route']))   {
            $this->request->get['route'] = 'product/product';
            $this->request->get['product_id'] = 42;
        }

if ( isset($this->request->get['route']) && $this->request->get['route'] == 'common/home' ){
            $this->request->get['route'] = 'product/product';
            $this->request->get['product_id'] = 42;

        }

You will need to change the product_id to the id of your product. e.g. $this->request->get['product_id'] = 102;

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!