我将进入Magento->Sales->Order,并尝试搜索“Bill to”上的全名(姓氏),但是没有得到任何结果。但是如果我只搜索名字(名字),我就会得到结果。如果我要去Magento-> Customers ->管理客户并尝试使用全名搜索,所有工作都是正确的。
这个搜索是在哪里实现的?有什么问题吗?
发布于 2016-05-06 12:49:42
发布于 2016-04-28 09:19:03
我以前见过这个。
如果您尝试在Bill to / Ship to order网格中搜索姓名+姓氏,则需要在名字和姓氏之间放置一个双空格,即:
不是:
John Smith试试这个:
John Smith唯一的区别是名字之间的双空格。我还没有看过,但我想象Magento将网格中的名称连接在一起,要么使用双空格,要么查找中间名,如果不存在,则输出一个空格。
奇怪,我知道!
发布于 2019-04-02 15:00:26
这只是为了网格,但它似乎是做我想做的。
protected function searchWithDoubleSpace($collection, $column)
{
if(!$value = trim($column->getFilter()->getValue()))
{
return $this;
}
//if there was a space input
elseif(preg_match('/ /', $value))
{
$revisedValue = str_replace(' ', ' ', $value); // replace a space with double space
$this->getCollection()->addAttributeToFilter($column->getData('index'), array(
array('like' => '%' . $value . '%'),
array('like' => '%' . $revisedValue.'%'))
); // search with both queries and includes results from both queries (OR)
}
else
{
$this->getCollection()->addAttributeToFilter($column->getData('index'), array('like' => '%'.$value.'%'));
}
return $this;
}如果有一个空间输入,则创建两个查询,一个是原样,另一个是双空间代替单个空间。最后,从这两个查询获得结果。
另外,不要忘记在列中添加这段代码
'filter_condition_callback' => array($this, 'searchWithDoubleSpace')https://stackoverflow.com/questions/36909578
复制相似问题