__('All', 'ai-eshop-optimizer'), 'ready' => __('Ready to merge', 'ai-eshop-optimizer'), 'review' => __('Worth a look first', 'ai-eshop-optimizer'), 'blocked' => __('Needs a decision', 'ai-eshop-optimizer'), ); $product_total = 0; foreach ($groups as $g) { $product_total += count($g['members']); } if (!function_exists('aieo_ds_pretty')) { function aieo_ds_pretty($value) { return (string) $value; } } ?> 'duplicate-simples-duplicate-products', 'title' => __('Detected groups', 'ai-eshop-optimizer'), 'description' => __('These groups were found automatically. Each one shows the evidence behind it, so you can judge it before doing anything. Preview always comes before a merge, and every merge can be undone.', 'ai-eshop-optimizer'), ); if (!$available) : list($aieo_ds_open, $aieo_ds_close) = AIEO_DMM_UI::card($aieo_ds_detected); echo $aieo_ds_open; $aieo_ds_note = \Rooster\Admin\States::state( 'not-run', array( 'title' => __('The similarity engine has not produced its data yet.', 'ai-eshop-optimizer'), 'text' => __('This report reads the semantic engine\'s product-similarity graph. Once the engine has indexed the catalogue, the groups appear here automatically.', 'ai-eshop-optimizer'), ) ); echo $aieo_ds_note; echo $aieo_ds_close; return; endif; list($aieo_ds_open, $aieo_ds_close) = AIEO_DMM_UI::card(array( 'anchor' => 'duplicate-simples-threshold', 'icon' => 'sliders-horizontal', 'title' => __('Threshold', 'ai-eshop-optimizer'), 'description' => __('A higher value groups fewer products, only near copies; a lower value catches more, with more false matches.', 'ai-eshop-optimizer'), 'footer' => \Rooster\Admin\States::save_button('aieo-card-duplicate-simples-threshold-form'), )); echo $aieo_ds_open; $aieo_ds_row = \Rooster\Admin\Ui::field_row(array( 'id' => 'aieo-ds-threshold', 'label' => __('How alike two products must be before they are grouped', 'ai-eshop-optimizer'), 'control' => \Rooster\Admin\Ui::input('threshold', number_format($threshold, 2, '.', ''), array( 'id' => 'aieo-ds-threshold', 'type' => 'number', 'xs' => true, 'min' => '0.5', 'max' => '1', 'step' => '0.01', )), 'help' => __('Higher finds fewer, safer groups. Lower finds more, including ranges that only look alike — twenty lipstick shades resemble each other as much as three colours of one hat, and they are not the same thing.', 'ai-eshop-optimizer'), )); echo AIEO_DMM_UI::card_form('aieo_dmm_dupsimple_save', 'duplicate_simples', 'aieo-card-duplicate-simples-threshold-form', '
' . $aieo_ds_row . '
'); echo $aieo_ds_close; list($aieo_ds_open, $aieo_ds_close) = AIEO_DMM_UI::card($aieo_ds_detected); echo $aieo_ds_open; ?> 0) : ?> $label) { if (empty($counts[$key]) && $key !== 'all') { continue; } $aieo_ds_views[] = \Rooster\Admin\Ui::badge( $label . ' ' . \Rooster\Admin\Ui::count(isset($counts[$key]) ? (int) $counts[$key] : 0), $show === $key ? 'primary' : 'mono', array('href' => add_query_arg(array('ds_show' => $key)), 'solid' => $show === $key, 'link_attrs' => $show === $key ? array('aria-current' => 'page') : array()) ); } echo ''; ?> __('No duplicate groups found at this threshold.', 'ai-eshop-optimizer')) : array('title' => __('Nothing in this view.', 'ai-eshop-optimizer'), 'clear' => remove_query_arg('ds_show')) ); echo $aieo_ds_empty; ?>

0) : ?>

__('Merge all shown groups', 'ai-eshop-optimizer')) ); echo $aieo_ds_ask; ?> __('Colour', 'ai-eshop-optimizer'), 'size' => __('Size', 'ai-eshop-optimizer'), 'quantity' => __('Quantity', 'ai-eshop-optimizer'), 'type' => __('Type', 'ai-eshop-optimizer'), ); $conf = (float) $g['confidence']; $conf_tone = ($conf >= 0.85) ? 'success' : (($conf >= 0.6) ? 'warning' : 'destructive'); ob_start(); ?> 'duplicate-simples-group-' . substr(md5((string) $g['key']), 0, 12), 'title' => sprintf(__('%s products', 'ai-eshop-optimizer'), number_format_i18n(count($g['members']))), 'level' => 3, 'class' => 'aieo-ds-group', 'tools' => $aieo_ds_pick, 'attrs' => array('data-group' => (string) $g['key']), )); echo $aieo_ds_g_open; $aieo_ds_facts = array(); ?> $data) : $distinct = array_values(array_unique(array_map('aieo_ds_pretty', array_values($data['values'])))); $aieo_ds_facts[] = \Rooster\Admin\Ui::badge((isset($axis_labels[$axis]) ? $axis_labels[$axis] : $axis) . ': ' . implode(', ', $distinct), 'info'); endforeach; ?> ' . implode(' ', $aieo_ds_facts) . '

'; ?> 'include', 'label' => __('Include', 'ai-eshop-optimizer'), 'type' => 'control', 'width' => '28px', 'header_html' => '', 'format' => array( 'render' => static function ($row) use ($ds_group_key) { return ''; }, ), ), array( 'key' => 'title', 'label' => __('Product', 'ai-eshop-optimizer'), 'type' => 'link', 'format' => array( 'href' => static function ($row) { return (string) $row['edit_link']; }, 'external' => true, ), ), array( 'key' => 'sku', 'label' => __('SKU', 'ai-eshop-optimizer'), 'type' => 'code', 'width' => '180px', ), ); foreach (array_keys($g['axes']) as $axis) { $ds_cols[] = array( 'key' => 'axis_' . $axis, 'label' => isset($axis_labels[$axis]) ? $axis_labels[$axis] : $axis, 'type' => 'control', 'width' => '120px', 'format' => array( 'render' => static function ($row) use ($axis, $ds_group_key, $axis_labels) { $value = (string) $row['axis_' . $axis]; if ('' !== $value) { return esc_html($value); } return \Rooster\Admin\Ui::input('', '', array( 'class' => 'aieo-ds-value', 'short' => true, 'id' => 'aieo-ds-value-' . substr(md5($ds_group_key), 0, 8) . '-' . (int) $row['id'] . '-' . sanitize_key($axis), 'placeholder' => __('Not in the title — name it', 'ai-eshop-optimizer'), 'aria-label' => (isset($axis_labels[$axis]) ? $axis_labels[$axis] : $axis) . ': ' . (string) $row['title'], 'attrs' => array('data-group' => $ds_group_key, 'data-product' => (string) (int) $row['id'], 'data-axis' => $axis), )); }, ), ); } $ds_cols[] = array( 'key' => 'price', 'label' => __('Price', 'ai-eshop-optimizer'), 'type' => 'text', 'width' => '100px', ); $ds_cols[] = array( 'key' => 'links', 'label' => '', 'type' => 'control', 'width' => '110px', 'nowrap' => true, 'format' => array( 'render' => static function ($row) { $out = ''; if ('' !== $row['edit_link']) { $out .= '' . esc_html__('Edit', 'ai-eshop-optimizer') . ''; } if ('' !== $row['permalink']) { $out .= ' | ' . '' . esc_html__('View', 'ai-eshop-optimizer') . ''; } return $out; }, ), ); $ds_rows = array(); foreach ($g['members'] as $m) { $ds_row = array( 'id' => (int) $m['id'], 'title' => (string) $m['title'], 'sku' => (string) $m['sku'], 'price' => (string) $m['price'], 'edit_link' => (string) ($m['edit_link'] ?? ''), 'permalink' => (string) ($m['permalink'] ?? ''), ); foreach ($g['axes'] as $axis => $data) { $ds_row['axis_' . $axis] = isset($data['values'][$m['id']]) ? aieo_ds_pretty($data['values'][$m['id']]) : ''; } $ds_rows[] = $ds_row; } AIEO_Table::render(array( 'sortable' => false, 'columns' => $ds_cols, 'rows' => $ds_rows, 'row_key' => 'id', 'table_data' => array('group' => $ds_group_key), 'page_id' => 'duplicate_simples', )); ?> 2) : ?>

'; foreach ($g['warnings'] as $w) { $aieo_ds_lost .= '
  • ' . esc_html($w) . '
  • '; } $aieo_ds_lost .= '

    ' . esc_html__('You can still merge it if that is what you want. The preview shows exactly what would happen.', 'ai-eshop-optimizer') . '

    '; echo \Rooster\Admin\Ui::notice('', 'warning', array('inline' => true, 'title' => __('Merging would lose something:', 'ai-eshop-optimizer'), 'detail' => $aieo_ds_lost)); ?> '; foreach ($g['blockers'] as $b) { $aieo_ds_why .= '
  • ' . esc_html($b) . '
  • '; } echo \Rooster\Admin\Ui::notice('', 'destructive', array('inline' => true, 'title' => __('Cannot be merged as it stands:', 'ai-eshop-optimizer'), 'detail' => $aieo_ds_why . '')); ?>

    \Rooster\Admin\Ui::notice('{text}', 'success', array('inline' => true)), 'fail' => \Rooster\Admin\Ui::notice('{text}', 'destructive', array('inline' => true)), ); ?>