Commit cf84cccb by lmf

优化产品列表页面URL错误问题

parent 3f2e1365
......@@ -266,7 +266,7 @@ class AbstractProduct extends \Magento\Framework\View\Element\Template
if (!isset($additional['_escape'])) {
$additional['_escape'] = true;
}
return "products/".$product->getUrlKey();
return $product->getUrlKey();
//return $product->getUrlModel()->getUrl($product, $additional);
}
......
......@@ -182,12 +182,13 @@ class Url extends \Magento\Framework\DataObject
if (!empty($requestPath)) {
$routeParams['_direct'] = $requestPath;
} else {
$routePath = 'catalog/product/view';
$routeParams['id'] = $product->getId();
$routeParams['s'] = $product->getUrlKey();
if ($categoryId) {
$routeParams['category'] = $categoryId;
}
$routeParams['_direct'] = "products/".$product->getUrlKey();
// $routePath = 'catalog/product/view';
// $routeParams['id'] = $product->getId();
// $routeParams['s'] = $product->getUrlKey();
// if ($categoryId) {
// $routeParams['category'] = $categoryId;
// }
}
// reset cached URL instance GET query params
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment