-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Description
Preconditions:
- Magento instance with several websites
- Each website has a specific domain (base url)
Steps to reproduce:
- Open a product page for a specific website in the admin area
- Use the $product->getProductUrl() method to retrieve product url
Expected result:
Returned product url relates to specified website
Actual result:
Magento always uses the 'admin' scope (and the default base url) to retrieve product url and returns incorrect url.
I'm trying to implement a custom indexer in Magento 2.0.4. The indexer should send product data to an external service. It is possible to get all store specific values of the product except the product url.
By calling the method $product->getProductUrl()
I'm always retreiving the product's url with the admin storekey in it. (for example http://HOST/admin/catalog/product/view/...
)
I've looked into the problem and the method getBaseUrl
in Magento\Framework\Url
offers the possiblity to override the url scope with the parameter _scope
.
In backend context the subclass Magento\Backend\Model\Url
is used and the call to _getScope() which is executed within the getBaseUrl() method always returns the admin store. Magento\Framework\Url::_getScope()
uses the data value of scope
instead.
I think that it should be possible to also override the scope in backend context.