Php 无法按客户全名搜索Magento Admin Sales
我将进入Magento->Sales->Orders,尝试在“Bill to”输入中搜索全名(姓名),但没有结果。但如果我只搜索name(name),我会得到结果。如果我去Magento->Customers->Manage Customers并尝试使用全名进行搜索,所有这些都能正常工作Php 无法按客户全名搜索Magento Admin Sales,php,magento,search,e-commerce,enterprise,Php,Magento,Search,E Commerce,Enterprise,我将进入Magento->Sales->Orders,尝试在“Bill to”输入中搜索全名(姓名),但没有结果。但如果我只搜索name(name),我会得到结果。如果我去Magento->Customers->Manage Customers并尝试使用全名进行搜索,所有这些都能正常工作 这个搜索是在哪里实现的?有什么问题吗?我以前就发现了 如果您尝试在“收货方/收货方”表格中搜索“姓名+姓氏”,则需要在“名字”和“姓氏”之间留出两个空格,即: 不是: 试试这个: John Smith 唯一
这个搜索是在哪里实现的?有什么问题吗?我以前就发现了 如果您尝试在“收货方/收货方”表格中搜索“姓名+姓氏”,则需要在“名字”和“姓氏”之间留出两个空格,即: 不是: 试试这个:
John Smith
唯一的区别是名称之间的双空格。我还没有看过,但我想象Magento将网格中的名称连接起来,或者使用双空格,或者它查找中间名称,如果不存在,则输出一个空格
奇怪,我知道 下面是一个解决方案,其中包含用于更新数据库中现有记录的正确重写和脚本:
这仅适用于网格,但它似乎满足了我的要求
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')
真奇怪!我将尝试了解它是如何连接的。Thanx:)
'filter_condition_callback' => array($this, 'searchWithDoubleSpace')