Th3Nic3Guy
Th3Nic3Guy

Reputation: 1979

How do I turn off redirect to mobile pages in SAP Hybris

I have a Hybris installation and my team has developed everything in the Desktop version of all the pages/tags/fragments/views.

Now my CSS Team says that they can handle the responsiveness via CSS but the Desktop version needs to be the page to be called.

My Problem is that when i open the site in mobile/emulator, the mobile paths to pages are called, finally returning a 404.

What can be done to turn this auto redirect feature off..??

Any ideas..?

I have checked the hmc and turned off channel for the Mobile, but that is only for electronics and apparels.

I am working on the b2c telco channel

Upvotes: 2

Views: 1426

Answers (4)

kabadisha
kabadisha

Reputation: 720

Add this:

# Disables the mobile version of the site. This can be made site specific like this:
# uiexperience.level.supported.b2ctelco=DESKTOP
uiexperience.level.supported=DESKTOP

To the project.properties file of your storefront extension.

It tells Hybris that you only want to support the desktop ui experience level. N.B. You will need to clear the cache/cookies on your mobile device before the change will take effect.

Upvotes: 1

Jsk1986
Jsk1986

Reputation: 9

If you have access to the hybris wiki you should check the following URL:

https://wiki.hybris.com/display/forum/Turning+off+mobile+site+ui+experience

Upvotes: 0

Benoit Vanalderweireldt
Benoit Vanalderweireldt

Reputation: 2989

First it's not an auto-redirect it's how InternalResourceViewResolver is implemented within Hybris, and if you want to get rid of this functionality you can update "com.yourAcceleratorPackahe.storefront.web.view.UiExperienceViewResolver" :

public String getViewName(final UiExperienceLevel uiExperienceLevel, String viewName)
{
    final String prefix = getUiExperienceViewPrefix().get(uiExperienceLevel);
    if (prefix != null)
    {
        if (viewName.startsWith(AbstractPageController.PAGE_ROOT + "addon:"))
        {
            viewName = viewName.replace(AbstractPageController.PAGE_ROOT + "addon:", "addon:"); // ...pages/addon:/<extension-name>/.../<component-view>....->....addon:/<extension-name>/.../<component-view>
        }

        if (viewName.startsWith("addon:"))
        {
            viewName = viewName.replace("addon:", ""); // ................................addon:/<extension-name>/cms/<component-view>....->..../<extension-name>/cms/<component-view>
            viewName = viewName.substring(1, viewName.length()); // ....................../<extension-name>/cms/<component-view>..........->....<extension-name>/cms/<component-view>
            final String extensionName = viewName.substring(0, viewName.indexOf('/')); // <extension-name>/cms/<component-view>...........->....<extension-name>
            viewName = viewName.substring(viewName.indexOf('/'), viewName.length()); // ..<extension-name>/cms/<component-view>...........->..../cms/<component-view>
            return getAddOnPrefix() + "/" + extensionName + "/" + prefix + viewName; // ..<addon-prefix>/<extension-name>/<ui-prefix>/cms/<component-view>
        }
        return prefix + viewName;
    }
    return getUnknownUiExperiencePrefix() + viewName;
}

I would configure the 'youStoreFrontExtension/web/webroot/WEB-INF/config/spring-mvc-config.xml' file this way :

<property name="uiExperienceViewPrefix">
    <map>
        <entry key="DESKTOP" value="${commerceservices.default.desktop.ui.experience:desktop}/"/>
        <entry key="MOBILE" value="${commerceservices.default.mobile.ui.experience:desktop}/"/>
    </map>
</property>
<property name="unknownUiExperiencePrefix" value="${commerceservices.default.desktop.ui.experience:desktop}/"/>

With you local.properties like this:

commerceservices.default.desktop.ui.experience=desktop
commerceservices.default.mobile.ui.experience=desktop

Under recent versions of the accelerator you have a responsive view folder, if it's the one you are using you should change desktop to responsive.

Upvotes: 1

El Jaoujat Youssef
El Jaoujat Youssef

Reputation: 48

The mechanism of redirection is implemented via the view resolver of spirngMVC you should find it on spring-mvc-config.xml file under your front extension.

To turn off redirect you should :

  1. Open the file and look for the bean with id viewResolver and
  2. change uiExperienceViewPrefix property to

              <property name="uiExperienceViewPrefix">
                    <map>
                        <entry key="DESKTOP" value="desktop/"/>
                        <entry key="MOBILE" value="desktop/"/>
                    </map>
                </property>
    

This will redirect all mobile views to desktop jsp pages .

El jaoujat

Upvotes: 0

Related Questions