简体   繁体   English

产品页面作为Opencart中的主页

[英]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. 我的opencart上只有一种产品,并且我希望该产品只出现在主页上,这样客户就不再会仅仅为了购买产品而进入任何页面。 How can I make this product as default homepage? 如何使该产品成为默认主页? or How can I make the url default to the url of this product? 或如何使该URL默认为该产品的URL? I'm using opencart. 我正在使用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)". “ Opencart管理员>产品>产品页面>布局标签>替代(主页)”。

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 这两项都需要您编辑/catalog/controller/common/home.php并将代码放置在public function index() {行之后,将123更改为产品ID

v1.5.x v1.5.x

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

v2.x + v3.x 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 如果要显示主页URL并显示产品,则可以编辑/index.php文件并添加以下代码

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. 您需要将product_id更改为产品的ID。 eg $request->get['product_id'] = 12; 例如$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... 在重定向特定产品页面作为主页的情况下,它相当不错,但是您在更改产品时需要更改重定向URL。

It is simple ->>>>>>>> $this->redirect($this->url->link('product/product', 'product_id=123')); 很简单->>>>>>>>> $ 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 系统->设计->布局->主页->编辑->在内容顶部设置优先级1中添加特色模块

OpenCart 2.3 OpenCart 2.3

file catalog/controller/startup/seo_url.php after 文件目录/控制器/启动/seo_url.php之后

// 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. 您需要将product_id更改为产品的ID。 eg $this->request->get['product_id'] = 102; 例如$this->request->get['product_id'] = 102;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM