64 parent::__construct(
$data);
77 private function getUrlInstance()
79 return $this->urlFactory->create();
91 $params[
'_scope_to_url'] =
true;
104 if ($useSid ===
null) {
105 $useSid = $this->sidResolver->getUseSessionInUrl();
124 return $this->filter->translitUrl($str);
146 $categoryId =
$product->getCategoryId();
150 $requestPath =
$product->getUrlDataObject()->getUrlRewrite();
151 $routeParams[
'_scope'] =
$product->getUrlDataObject()->getStoreId();
153 $requestPath =
$product->getRequestPath();
154 if (empty($requestPath) && $requestPath !==
false) {
163 $rewrite = $this->urlFinder->findOneByData($filterData);
165 $requestPath =
$rewrite->getRequestPath();
166 $product->setRequestPath($requestPath);
173 if (isset($routeParams[
'_scope'])) {
174 $storeId = $this->storeManager->getStore($routeParams[
'_scope'])->getId();
177 if (
$storeId != $this->storeManager->getStore()->getId()) {
178 $routeParams[
'_scope_to_url'] =
true;
181 if (!empty($requestPath)) {
182 $routeParams[
'_direct'] = $requestPath;
184 $routePath =
'catalog/product/view';
185 $routeParams[
'id'] =
$product->getId();
186 $routeParams[
's'] =
$product->getUrlKey();
188 $routeParams[
'category'] = $categoryId;
193 if (!isset($routeParams[
'_query'])) {
194 $routeParams[
'_query'] = [];
197 return $this->getUrlInstance()->setScope(
$storeId)->getUrl($routePath, $routeParams);
getUrl(\Magento\Catalog\Model\Product $product, $params=[])
getUrlInStore(\Magento\Catalog\Model\Product $product, $params=[])
getProductUrl($product, $useSid=null)
__construct(\Magento\Framework\UrlFactory $urlFactory, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Framework\Filter\FilterManager $filter, \Magento\Framework\Session\SidResolverInterface $sidResolver, UrlFinderInterface $urlFinder, array $data=[])
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE]