使用 sugarCRM 6.5+ 在自定义模块上启用全局搜索


Enabling Global Search on Custom module with sugarCRM 6.5+

我一直在寻找,似乎找不到解决方案。我在灯堆栈上运行 6.5.15 CE,我在模块生成器中创建了 2 个自定义模块并在工作室中编辑了它们。客户和订单,订单模块显示为客户模块的子面板。我让全局搜索在客户模块上工作得很好,但不能在订单模块上工作。首先,我尝试了一个示例,该示例声明创建以下页面/custom/Extension/modules/cb_orders/ext/Vardefs/customGlobalSearchFields.php该页面不起作用,因此我将模块和字段名称添加到custom/modules/cb_orders/EXT/Vardefs/vardefs.php

<?php
// define custom fields to be included in the search algorithm!
$dictionary['cb_orders']['unified_search'] = true;
$dictionary['cb_orders']['unified_search_default_enabled'] = true;
// order number
$dictionary['cb_orders']['fields']['cb_order_number']['rname'] = 'cb_order_number';
$dictionary['cb_orders']['fields']['cb_order_number']['vname'] = 'LBL_CB_ORDER_NUMBER';
$dictionary['cb_orders']['fields']['cb_order_number']['type'] = 'TextField';
$dictionary['cb_orders']['fields']['cb_order_number']['dbType'] = 'varchar';
$dictionary['cb_orders']['fields']['cb_order_number']['table'] = 'cb_orders';
$dictionary['cb_orders']['fields']['cb_order_number']['unified_search_default_enabled'] = true;
//$dictionary['cb_orders']['unified_search'] = true;
// tracking number
$dictionary['cb_orders']['fields']['cb_shipping_tracking_number']['rname'] =    'cb_shipping_tracking_number';
$dictionary['cb_orders']['fields']['cb_shipping_tracking_number']['vname'] = 'LBL_CB_SHIPPING_TRACKING_NUMBER';
$dictionary['cb_orders']['fields']['cb_shipping_tracking_number']['type'] = 'TextField';
$dictionary['cb_orders']['fields']['cb_shipping_tracking_number']['dbType'] = 'varchar';
$dictionary['cb_orders']['fields']['cb_shipping_tracking_number']['table'] = 'cb_orders';
$dictionary['cb_orders']['fields']['cb_shipping_tracking_number']['unified_search_default_enabled'] = true;
//$dictionary['cb_orders']['unified_search'] = true;
// order description
$dictionary['cb_orders']['fields']['order_description']['rname'] = 'order_description';
$dictionary['cb_orders']['fields']['order_description']['vname'] = 'LBL_ORDER_DESCRIPTION';
$dictionary['cb_orders']['fields']['order_description']['type'] = 'TextField';
$dictionary['cb_orders']['fields']['order_description']['dbType'] = 'varchar';
$dictionary['cb_orders']['fields']['order_description']['table'] = 'cb_orders';
$dictionary['cb_orders']['fields']['order_description']['unified_search_default_enabled'] = true;
//$dictionary['cb_orders']['unified_search'] = true;
// shipping company used
$dictionary['cb_orders']['fields']['cb_orders_shipping_company']['rname'] = 'cb_orders_shipping_company';
$dictionary['cb_orders']['fields']['cb_orders_shipping_company']['vname'] = 'LBL_CB_ORDERS_SHIPPING_COMPANY';
$dictionary['cb_orders']['fields']['cb_orders_shipping_company']['type'] = 'TextField';
$dictionary['cb_orders']['fields']['cb_orders_shipping_company']['dbType'] = 'varchar';
$dictionary['cb_orders']['fields']['cb_orders_shipping_company']['table'] = 'cb_orders';
$dictionary['cb_orders']['fields']['cb_orders_shipping_company']['unified_search_default_enabled'] = true;
//$dictionary['cb_orders']['unified_search'] = true;
// which cart the order came from
$dictionary['cb_orders']['fields']['cb_referrer_c']['rname'] = 'cb_referrer_c';
$dictionary['cb_orders']['fields']['cb_referrer_c']['vname'] = 'LBL_CB_REFERRER';
$dictionary['cb_orders']['fields']['cb_referrer_c']['type'] = 'TextField';
$dictionary['cb_orders']['fields']['cb_referrer_c']['dbType'] = 'varchar';
$dictionary['cb_orders']['fields']['cb_referrer_c']['table'] = 'cb_orders';
$dictionary['cb_orders']['fields']['cb_referrer_c']['unified_search_default_enabled'] = true;
//$dictionary['cb_orders']['unified_search'] = true;
// date and time ordered
$dictionary['cb_orders']['fields']['date_time_ordered_c']['rname'] = 'date_time_ordered_c';
$dictionary['cb_orders']['fields']['date_time_ordered_c']['vname'] = 'LBL_DATE_TIME_ORDERED';
$dictionary['cb_orders']['fields']['date_time_ordered_c']['type'] = 'TextField';
$dictionary['cb_orders']['fields']['date_time_ordered_c']['dbType'] = 'varchar';
$dictionary['cb_orders']['fields']['date_time_ordered_c']['table'] = 'cb_orders_cstm';
$dictionary['cb_orders']['fields']['date_time_ordered_c']['unified_search_default_enabled'] = true;
//$dictionary['cb_orders']['unified_search'] = true;
// last four of social
$dictionary['cb_orders']['fields']['cb_lastfour_c']['rname'] = 'cb_lastfour_c';
$dictionary['cb_orders']['fields']['cb_lastfour_c']['vname'] = 'LBL_CB_LASTFOUR';
$dictionary['cb_orders']['fields']['cb_lastfour_c']['type'] = 'TextField';
$dictionary['cb_orders']['fields']['cb_lastfour_c']['dbType'] = 'varchar';
$dictionary['cb_orders']['fields']['cb_lastfour_c']['table'] = 'cb_orders_cstm';
$dictionary['cb_orders']['fields']['cb_lastfour_c']['unified_search_default_enabled'] = true;
//$dictionary['cb_orders']['unified_search'] = true;

文件和自定义/模块/cb_orders/元数据/搜索字段.php 文件,如 Sugar 论坛上的示例所示。

$searchFields['cb_orders']['cb_order_number'] = array('query_type' => 'default');
$searchFields['cb_orders']['cb_shipping_tracking_number'] = array('query_type' => 'default');
$searchFields['cb_orders']['order_description'] = array('query_type' => 'default');
$searchFields['cb_orders']['cb_orders_shipping_company'] = array('query_type' => 'default');
$searchFields['cb_orders']['cb_referrer_c'] = array('query_type' => 'default');
$searchFields['cb_orders']['date_time_ordered_c'] = array('query_type' => 'default');

重建后,我似乎仍然无法搜索该模块。

这可能是由于一对多关系(一个客户对多个订单)造成的吗?

我不知道

你是否曾经得到过这个工作,但我注意到你有,作为你的路径

custom/modules/cb_orders/metadata/searchfields.php

什么时候应该

custom/modules/cb_orders/metadata/SearchFields.php

(搜索字段中的大写 S 和 F.php)

就第一条路径而言

custom/Extension/modules/cb_orders/ext/Vardefs/customGlobalSearchFields.php

您可以使用任何文件名,它不必是 vardefs.php检查

custom/modules/cb_orders/Ext/Vardefs/vardefs.ext.php 

文件以确认在修复和重建中捕获了添加内容,而不考虑文件名。

你有没有在不需要做admin -> Global Search -> Drag&Drop的情况下完成这项工作?

我必须另外删除/cache/modules/unified_search_modules.php才能让它工作。删除后,搜索后将再次生成。