[2.1] Unable to get store URL from admin #5322

Open
acharrex opened this Issue Jun 28, 2016 · 1 comment

Projects

None yet

4 participants

@acharrex
acharrex commented Jun 28, 2016 edited

Steps to reproduce

  1. Install Magento 2.1 from develop branch.
  2. Run the following code from the admin area (by example from a controller):
$url = $this->_objectManager->get('Magento\Store\Model\StoreManagerInterface')
    ->getStore(1) // 1 = default store id
    ->getUrl('myroute')

echo $url;

Expected result

http://mymagentoshop.local/myroute

Actual result

Magento returns an URL prefixed with the admin path:

http://mymagentoshop.local/admin_XXXX/myroute

Note

The following code:

$url = $this->_objectManager->get('Magento\Store\Model\StoreManagerInterface')
    ->getStore($customer->getStoreId())
    ->getBaseUrl();

Works correctly:

http://mymagentoshop.local/

This problem seems to be limited to the "getUrl" method.

This issue was not present with Magento 2.0.7.

@acharrex acharrex changed the title from [2.1] Unable get store URL from admin to [2.1] Unable to get store URL from admin Jun 28, 2016
@veloraven veloraven added the bug label Aug 1, 2016
@sfedosimov

I have the same issue on Magento 2.1.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment