1

I'm completely new to Magento (used WordPress a lot before and sites from scratch) and I cannot understand how to change the homepage so it will show the sign in page.

I'm using the standard luma theme, so there is already an existing page, I would like to redirect the controller to the sign in URL but for the life of me can't understand the architecture.

Hoping to solve this simple problem. Please help me understand Magento better.
Thanks in advance

  • are you looking programmatic solution? it is possible from admin too. – Bilal Usean Sep 13 '16 at 15:35
  • I would like a programmatic solution. I feel like it would help me understand how things work in a practical way. Thanks! – N. Mantel Sep 13 '16 at 16:05
1

First create simple module, refer this link for step by step implementation after that follow the instruction.

Default home page for luma is cms/index/index, so you need to override that controller in order to redirect.

for override the controler add the below content in your app/code/vendor/namespace/etc/di.xml

<?xml version="1.0"?>
<!--
/**
 * Copyright © 2015 Magento. All rights reserved.
 * See COPYING.txt for license details.
 */
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd">
    <preference for="Magento\Cms\Controller\Index\Index" type="MyVendor\MyNamespace\Controler\Index\Redirecthome" />
</config>

New Custom Controller: app/code/Vendor/namespace/Controler/Index/Redirecthome.php

<?php
namespace MyVendor\MyNamespace\Controller\Index;
class Redirecthome extends \Magento\Framework\App\Action\Action
{
    protected $resultForwardFactory;
    public function __construct(
        \Magento\Framework\App\Action\Context $context,
        \Magento\Framework\Controller\Result\ForwardFactory $resultForwardFactory
    ) {
        $this->resultForwardFactory = $resultForwardFactory;
        parent::__construct($context);
    }

    public function execute($coreRoute = null)
    {
       $this->_redirect('customer/account/login');
                return;
    }
}

Now the home page use the above controller instead of default. I have tested it works.

From Admin: It is possible from admin too

Home Page:

store -> configuration -> General -> Web -> Default pages -> here you can chnge **cms** to **customer/account/login**

Redirection

marketing -> url rewrite -> add new url rewrite -> here you can set request path as **cms** and target path as **customer/account/login**
  • Thank you that was extremely helpful in all the magento chaos! – N. Mantel Sep 13 '16 at 18:33
0

Better solution is not writing any extra code.

Go to Admin Page.

Select Marketing => URL Rewrites

Click on Add URL Rewrites

Set Create URL Rewrite to "Custom"

Store as "Default Store view".

Request Path as "\"

Target Path as "Whatever you want"

Redirect Type "Whatever you want"

Description as "Whatever you want"

Save it. And check. No need to write some extra stuff.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.