Commit cf84cccb by lmf

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

parent 3f2e1365
...@@ -266,7 +266,7 @@ class AbstractProduct extends \Magento\Framework\View\Element\Template ...@@ -266,7 +266,7 @@ class AbstractProduct extends \Magento\Framework\View\Element\Template
if (!isset($additional['_escape'])) { if (!isset($additional['_escape'])) {
$additional['_escape'] = true; $additional['_escape'] = true;
} }
return "products/".$product->getUrlKey(); return $product->getUrlKey();
//return $product->getUrlModel()->getUrl($product, $additional); //return $product->getUrlModel()->getUrl($product, $additional);
} }
......
...@@ -182,12 +182,13 @@ class Url extends \Magento\Framework\DataObject ...@@ -182,12 +182,13 @@ class Url extends \Magento\Framework\DataObject
if (!empty($requestPath)) { if (!empty($requestPath)) {
$routeParams['_direct'] = $requestPath; $routeParams['_direct'] = $requestPath;
} else { } else {
$routePath = 'catalog/product/view'; $routeParams['_direct'] = "products/".$product->getUrlKey();
$routeParams['id'] = $product->getId(); // $routePath = 'catalog/product/view';
$routeParams['s'] = $product->getUrlKey(); // $routeParams['id'] = $product->getId();
if ($categoryId) { // $routeParams['s'] = $product->getUrlKey();
$routeParams['category'] = $categoryId; // if ($categoryId) {
} // $routeParams['category'] = $categoryId;
// }
} }
// reset cached URL instance GET query params // 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