문제

How can I remove SKU from product name in search results? In category view, product name is without SKU but when I search for some product, the results is including SKU in product name.

도움이 되었습니까?

해결책

I found the solution

<?php
/**
 * Copyright © 2015 Magento. All rights reserved.
 * See COPYING.txt for license details.
 */
namespace theme\mytheme\Model\Plugin;

class Product
{
     public function afterGetName(\Magento\Catalog\Model\Product $subject, $result)
    {
      $objectManager = \Magento\Framework\App\ObjectManager::getInstance();
      $requestInterface = $objectManager->get('Magento\Framework\App\RequestInterface');

      $routeName      = $requestInterface->getRouteName();

      if($routeName=='catalogsearch')
      {
          return str_replace ( $subject->getSku() , "",$result ) ;
      }
      return $result;
    }

}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 magento.stackexchange
scroll top