hello1010
hello1010

Reputation: 41

Product page as homepage in Opencart

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)".

Upvotes: 2

Views: 4122

Answers (4)

Jay Gilford
Jay Gilford

Reputation: 15151

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'));

Upvotes: 2

Sergo
Sergo

Reputation: 111

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;

Upvotes: 0

Kevin
Kevin

Reputation: 13

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

Upvotes: 0

GeorgeQ
GeorgeQ

Reputation: 1382

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;

Upvotes: 2

Related Questions