Product page as homepage in Opencart

2019-05-28 11:12发布

I have only one product on my opencart and I want this product just to be in the homepage so that the customer will no longer go to any page just to buy the product. How can I make this product as default homepage? or How can I make the url default to the url of this product? I'm using opencart. I've tried to override the layout of the product but it didn't work. "Opencart Admin > Product > Porduct Page > Layout Tab > Override (Home)".

4条回答
smile是对你的礼貌
2楼-- · 2019-05-28 11:17

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

查看更多
Rolldiameter
3楼-- · 2019-05-28 11:20

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'));
查看更多
Emotional °昔
4楼-- · 2019-05-28 11:23

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;

查看更多
该账号已被封号
5楼-- · 2019-05-28 11:31

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;

查看更多
登录 后发表回答