'' ) AS has_needs, CASE WHEN n.selected_needs IS NULL OR n.selected_needs = '' THEN 0 ELSE LENGTH( n.selected_needs ) - LENGTH( REPLACE( n.selected_needs, ',', '' ) ) + 1 END AS needs_count, pv.brand, pv.menu_category, pv.head_category, pv.sku, pv.gtin FROM {prefix}aieo_dmm_product_needs n LEFT JOIN {prefix}aieo_core_product_vitals pv ON pv.product_id = n.product_id "; return array( 'id' => 'insights_product_needs', 'label' => 'Needs coverage', 'description' => 'Every product with a needs record: which need terms it carries, and which products carry none, so the Needs filtering on the shop stays complete.', 'footnote' => 'Product names, SKUs and categories come from the live product vitals, so they cannot drift the way the frozen copy this replaces did. A product with an empty Needs cell has a record and no assignment — that is the row to work on.', 'group' => 'catalog_sync', 'section' => 'catalogue', 'icon' => 'clipboard-check', 'menu_priority' => 61, 'tier' => 'pro', 'scope' => 'both', 'source' => 'sql', 'sql' => $aieo_pn_sql, 'registry_id' => 'insights_t28.needs_filters', 'version' => '1', 'per_page' => 50, 'row_key' => 'product_id', 'default_sort' => array( 'product_id', 'desc' ), 'empty_state' => 'No needs records yet. Rows appear as products are given need terms in the Product Needs editor.', 'actions' => array( array( 'id' => 'edit_needs', 'label' => 'Edit needs', 'intent' => array( 'name' => 'product_needs', 'key' => 'product_id' ), 'capability' => 'edit_products', ), ), 'columns' => array( array( 'key' => 'product_id', 'label' => 'Product ID', 'type' => 'id', 'sortable' => true, 'searchable' => true, ), array( 'key' => 'image_url', 'label' => '', 'sr_label' => 'Product image', 'type' => 'image', 'format' => array( 'size' => 44, 'rehost' => true ), 'width' => '58px', 'sortable' => false, 'empty' => '', ), array( 'key' => 'name', 'label' => 'Product', 'type' => 'text', 'sortable' => true, 'searchable' => true, 'filter' => 'text', 'truncate' => 48, 'tooltip' => true, ), array( 'key' => 'selected_needs', 'label' => 'Needs', 'type' => 'text', 'searchable' => true, 'truncate' => 60, 'tooltip' => true, 'empty' => '—', ), array( 'key' => 'has_needs', 'label' => 'Assigned', 'type' => 'boolean', 'filter' => 'select', ), array( 'key' => 'needs_count', 'label' => 'Count', 'type' => 'integer', 'sortable' => true, 'filter' => 'number_range', 'empty_zero' => true, ), array( 'key' => 'brand', 'label' => 'Brand', 'type' => 'text', 'sortable' => true, 'filter' => 'select', ), array( 'key' => 'menu_category', 'label' => 'Menu category', 'type' => 'text', 'sortable' => true, 'filter' => 'select', ), array( 'key' => 'head_category', 'label' => 'Head category', 'type' => 'text', 'filter' => 'select', 'hidden' => true, ), array( 'key' => 'sku', 'label' => 'SKU', 'type' => 'code', 'sortable' => true, 'searchable' => true, ), array( 'key' => 'gtin', 'label' => 'GTIN', 'type' => 'code', 'searchable' => true, 'hidden' => true, ), ), );