Saturday, August 13, 2016

Opencart 2.3 landing page Bisection

I am new to opencart 2.3 and i am learning through debugging how this e-commerce platform working.

In this post , i am writing about changing landing page which is changing route common/home to something new. i.e uncommon/home

I have been trying to find the root from where opencart 2.3 is routing to common/home.  After few hours (i am slow at learning but persistent )i found that the default route is found from system/config/default.php file.

If you look carefully , you can see
$_['action_default']        = 'common/home';
this line.
So if we change  the value of
$_['action_default']
then we can route to different landing page.

Now, my intention was to setting up different landing page and the test route was decided as  uncommon/home.

To make it work, first i copied all the files from catalog/controller/common directory to a new directory called catalog/controller/uncommon.

Now change all the class name under catalog/controller/uncommon directory as follow:
  • Cart.php file
      ControllerCommonCart to ControllerUncommonCart 
  • column_left.php file
      ControllerCommonColumnLeft to ControllerUncommonColumnLeft
Now replace all occurrence of common common with uncommon.

Do exactly same for all other files under uncommon directory.


Now lets create view files for all these controller to show data.

Go to catalog/view/theme/default/template directory.

Copy all files from catalog/view/theme/default/template/common  to catalog/view/theme/default/template/uncommon directory.

So our basic setup completed. Now we'll change default route to our new created route.

To do so, we have to change value of 
$_['action_default'] as  'uncommon/home'

Finally Login as admin in your projec and go to layouts section.
Select home and click edit button.
Now change the route
'common/home' to 'uncommon/home'
Now we are done our all set up.
If we browse our project's landing directory, we'll see our newly created pages which are showing by routing
'uncommon/home'
Now change the files under uncommon directory as you like and reload browser to see the updates.

0 comments:

Post a Comment