Coder Social home page Coder Social logo

opengento / magento2-store-path-url Goto Github PK

View Code? Open in Web Editor NEW
7.0 7.0 0.0 55 KB

This module allows to override the store code in url with an other path value.

License: MIT License

PHP 100.00%
adobe-commerce adobe-commerce-extension adobecommerce baseurl baseurl-domain magento magento-2 magento-extension magento-module magento2

magento2-store-path-url's Introduction

Store Path Url Module for Magento 2

Latest Stable Version License: MIT Packagist Packagist

This module allows to override the store code in url with another path value.

Setup

Magento 2 Open Source or Commerce edition is required.

Composer installation

Run the following composer command:

composer require opengento/module-store-path-url

Setup the module

Run the following magento command:

bin/magento setup:upgrade

If you are in production mode, do not forget to recompile and redeploy the static resources.

Features

The module allows to replace the store code in url with the following options:

  • Country Code, e.g: be
  • Language Code, e.g: fr
  • Locale Code (separated with a hyphen), e.g: fr-be
  • Locale Code (separated with an underscore), e.g: fr_be
  • Custom (you can setup the path of your choice), e.g: emea

This module also allows you to remove the store path in the url for websites with a single store view. This may be useful for stores with dedicated domains. This setting is automatically enabled if you choose to use the custom mapper. However, if a single store exists for a website, and a path is setup within the mapper, the path is not unset, meaning that the path configured in the mapper is used.

Besides that, this module makes the usage of the MAGE_RUN_TYPE and MAGE_RUN_CODE variables optionals. Magento is going to be able to resolve the correct store based on its base web URL. This setting can be disabled, see "Use Base Url Resolver".

Settings

The configuration for this module is available in Stores > Configuration > Web > Url.

Documentation

In order to use this module, you must enable the following setting: "Add Store Code to Urls" (web/url/use_store).
A new field is added in the configuration: "Store Path Url" and "Custom Path Mapper" if the "custom" value is selected.
The store path config are:

  • web/url/store_path_url
  • web/url/custom_path_mapper
  • unset_single_store_path
  • base_url_resolver

Support

Raise a new request to the issue tracker.

Authors

  • Opengento Community - Lead - Twitter Follow
  • Thomas Klein - Maintainer - GitHub followers
  • Contributors - Contributor - GitHub contributors

License

This project is licensed under the MIT License - see the LICENSE details.

That's all folks!

magento2-store-path-url's People

Contributors

thomas-kl1 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

magento2-store-path-url's Issues

Add an option to disabled path for website with single store

Multi-websites applications may have a single store for some websites. For those website's stores we want to have an option to hide the store path in the url.
Add a warning that Magento may can't resolve the correct store if it shares the same base url as an other (shouldn't apply on multiple brands websites with different domains configured in base urls).

Memory leak due to native error (from non secure uri)

\Magento\Store\Model\Store::isCurrentlySecure

$secureBaseUrl = $this->_config->getValue(self::XML_PATH_SECURE_BASE_URL, ScopeInterface::SCOPE_STORE);
$secureFrontend = $this->_config->getValue(self::XML_PATH_SECURE_IN_FRONTEND, ScopeInterface::SCOPE_STORE);

This methods tries to resolve the configuration from the current active store instead of the internal state ID of the object.
Passing the own object ID fix it:

$secureBaseUrl = $this->_config->getValue(self::XML_PATH_SECURE_BASE_URL, ScopeInterface::SCOPE_STORE, $this->getId());
$secureFrontend = $this->_config->getValue(self::XML_PATH_SECURE_IN_FRONTEND, ScopeInterface::SCOPE_STORE, $this->getId());

Because the scope ID is not passed by, Magento core try to resolve the current store ID, which is already what the system is currently trying to achieve.

magento/magento2#38717

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.