Commit 68b191c1 by wd

修改网址参数以及添加空格

parent 7f499fd9
...@@ -38,11 +38,11 @@ class CategoryLoadAfter implements \Magento\Framework\Event\ObserverInterface ...@@ -38,11 +38,11 @@ class CategoryLoadAfter implements \Magento\Framework\Event\ObserverInterface
{ {
$category = $observer->getEvent()->getCategory(); $category = $observer->getEvent()->getCategory();
if ($category instanceof \Magento\Catalog\Model\Category) { if ($category instanceof \Magento\Catalog\Model\Category) {
$url = ltrim(parse_url($this->url->getBaseUrl())['host'],'www.');
$str = $this->getUrlParameter($category); $str = $this->getUrlParameter($category);
$oldMetaDescription = $category->getMetaDescription(); $oldMetaDescription = $category->getMetaDescription();
$oldMetaKeyword = $category->getMetaKeywords(); $oldMetaKeyword = $category->getMetaKeywords();
$category->setMetaTitle('Buy the Latest ' . $str['title'] .' on '.$this->url->getBaseUrl()); $category->setMetaTitle('Buy the Latest ' . $str['title'] .' on '.$url);
$category->setMetaDescription('Shop ' . $str['title'] . '. ' . $oldMetaDescription); $category->setMetaDescription('Shop ' . $str['title'] . '. ' . $oldMetaDescription);
if ($str['keyword'] && $str['keyword'] != '.'){ if ($str['keyword'] && $str['keyword'] != '.'){
$category->setMetaKeywords($str['keyword']); $category->setMetaKeywords($str['keyword']);
...@@ -83,7 +83,6 @@ class CategoryLoadAfter implements \Magento\Framework\Event\ObserverInterface ...@@ -83,7 +83,6 @@ class CategoryLoadAfter implements \Magento\Framework\Event\ObserverInterface
$arr['title'] .= $price .' '; $arr['title'] .= $price .' ';
$arr['keyword'] .= $price .' '. $categoryName.','; $arr['keyword'] .= $price .' '. $categoryName.',';
} }
$arr['title'] = rtrim($arr['title'],' ');
$arr['title'] .= $categoryName; $arr['title'] .= $categoryName;
$arr['keyword'] = rtrim($arr['keyword'],',') . '.'; $arr['keyword'] = rtrim($arr['keyword'],',') . '.';
......
...@@ -69,7 +69,8 @@ class ViewPlugin ...@@ -69,7 +69,8 @@ class ViewPlugin
$pageConfig = $this->resultPage->getConfig(); $pageConfig = $this->resultPage->getConfig();
$title = $product->getMetaTitle(); $title = $product->getMetaTitle();
if (!$title){ if (!$title){
$pageConfig->getTitle()->set('$'.$product->getFinalPrice() . ' - ' .$product->getName() . ' Online at '.$this->urlInterface->getBaseUrl()); $url = ltrim(parse_url($this->urlInterface->getBaseUrl())['host'],'www.');
$pageConfig->getTitle()->set('$'.$product->getFinalPrice() . ' - ' .$product->getName() . ' Online at '.$url);
} }
} }
...@@ -83,7 +84,8 @@ class ViewPlugin ...@@ -83,7 +84,8 @@ class ViewPlugin
$description = $product->getMetaDescription(); $description = $product->getMetaDescription();
if (!$description) { if (!$description) {
$pageConfig->setDescription('Buy ' . $product->getName() . ' Online at the Price of $' . $product->getFinalPrice() .' at '.$this->urlInterface->getBaseUrl() . '.' . ' You Will Get the Best Service and Worldwide Free Shipping for Orders $69+.'); $url = ltrim(parse_url($this->urlInterface->getBaseUrl())['host'],'www.');
$pageConfig->setDescription('Buy ' . $product->getName() . ' Online at the Price of $' . $product->getFinalPrice() .' at '. $url . '.' . ' You Will Get the Best Service and Worldwide Free Shipping for Orders $69+.');
} }
} }
......
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