Нужно, чтобы данные из массива выводились только когда происходит поиск по нему. Не уверен, что этот код отвечает за это. Не нужно, чтобы сразу подгружались все данные или ограничить 5.
// Attributes
$('#mm_attribute_new').autocomplete({
'delay': 250,
'source': function(request, response) {
$.ajax({
url: 'index.php?route=seller/account-product/jxAutocompleteAttributes&filter_name=' + encodeURIComponent(request),
dataType: 'json',
success: function(json) {
var existing_attrs = [];
$.map($(document).find('.mm_attribute').not('.ffSample'), function(attribute_row) {
existing_attrs.push($(attribute_row).find('input[name^="product_attribute"][name$="[name]"]').val());
});
response($.map(json, function(item) {
if($.inArray(item.name, existing_attrs) == -1) {
return {
category: item.attribute_group,
label: item.name,
value: item.attribute_id
}
}
}));
}
});
},
'select': function(item) {
$(this).parents('#mm_product_attributes').find('.mm_clone').click();
var newAttr = $(this).parents('#mm_product_attributes').find('.form-group:last');
newAttr.find('input[name$="[attribute_id]"]').val(item['value']);
newAttr.find('input[name^="product_attribute"][name$="[name]"]').val(item['label']);
newAttr.find('label').append(item['label']);
newAttr.find('textarea').focus();
$(this).blur();
}
});