I am trying to redirect home page catalog/controller/common/home.php in opencart. In the php file, after this line public function index() { and before this line $this->config->get('config_meta_title')); When I add $this->response->redirect($this->url->link('product/product', 'product_id=50')); it redirects and works when a user visits opencart home page. I need to create OCMOD file to achieve the same thing without modifying the core code in this php file. Also I don't want to use htaccess redirect. I tried the below code but not working. I am not that much knowledgable in XML or PHP. hence please help. The OCMOD code I tried is below:
<name>Product page as home page</name>
<id>Product page as home page</id>
<version>1.0.0</version>
<code>Product page as home page</code>
<author>test</author>
<link>#</link>
<file path="catalog/controller/common/home.php">
<operation>
<search><![CDATA[if (isset($this->document->setTitle($this->config->get('config_meta_title'));'])) {]]></search>
<add position="before"><![CDATA[
$this->response->redirect($this->url->link('product/product', 'product_id=50'));
]]></add>
</operation>
</file>
Please help. Thanks and regards VSR
There it is not ocmod. this is vqmod. OCMOD here:
<?xml version="1.0" encoding="UTF-8"?>
<modification>
<name>Product page as home page</name>
<version>1.0.0</version>
<code>Product page as home page</code>
<author>test</author>
<link>#</link>
<file path="catalog/controller/common/home.php">
<operation>
<search><![CDATA[if (isset($this->document->setTitle($this->config->get('config_meta_title'));'])) {]]></search>
<add position="before"><![CDATA[
$this->response->redirect($this->url->link('product/product', 'product_id=50'));
]]></add>
</operation>
</file>
</modification>
And carefully check your string which is in the ocmod search tag... if (isset($this->document->setTitle($this->config->get('config_meta_title'));'])) {
it is correct? Seems the string is incorrect.
EDITED regarding your comment:
<?xml version="1.0" encoding="UTF-8"?>
<modification>
<name>Product page as home page</name>
<version>1.0.0</version>
<code>Product page as home page</code>
<author>test</author>
<link>#</link>
<file path="catalog/controller/common/home.php">
<operation>
<search><![CDATA[public function index() {]]></search>
<add position="after"><![CDATA[
$this->response->redirect($this->url->link('product/product', 'product_id=50'));
]]></add>
</operation>
</file>
</modification>