Basic search API integration.
[sandbox/serialjaywalker/1195272.git] / modules / search / includes / commerce_pos_search_status_filter.inc
1 <?php
2
3 /**
4 * Data alteration callback that filters out disabled Commerce entities.
5 */
6 class CommercePosSearchStatusFilter extends SearchApiAbstractAlterCallback {
7
8 /**
9 * @param SearchApiIndex $index
10 * @return bool
11 */
12 public function supportsIndex(SearchApiIndex $index) {
13 return in_array($index->item_type, array('commerce_product', 'commerce_customer_profile'));
14 }
15
16 /**
17 * Exclude items that doesn't have a product reference field attached to
18 * the bundle.
19 */
20 public function alterItems(array &$items) {
21 foreach ($items as $id => $item) {
22 if (empty($item->status)) {
23 unset($items[$id]);
24 }
25 }
26 }
27
28 }