0

We have 40000+ products on our site and have a custom product archive page for manufacturers. Each product per manufacturer has an attribute 'pa_series' that they belong to. Some series have 100's of products. I am trying to only show 1 product per series. How would I only show manufacturer products with unique series (or just the first result per series)?

Example:
product 1: series 1
product 2: series 1
product 3: series 2
product 4: series 2
product 5: series 2
product 6: series 3

Display product 1, skip product 2, display product 3, skip product 4 and 5, display product 6

this is what I have so far. I am just having a problem showing only 1 product per series(unique). If that makes sense.

if ( have_posts() ) :

while ( have_posts() ) : the_post();

if(is_product_category('manufacturer' . strstr($man_cat->slug, '-'))) :

$post_loop_count ++;
$loop_counter ++;
if($loop_counter === 1)
{
    echo "<div class='{$grid} {$extraClass} flex_column catalogue-column'>";
    echo "<div class='catalogue-container catalogue-container-woo' >";
    echo "<ul class='catalogue-list'>";
    $extraClass = "";
}

    global $product;

    $link       =   $product->add_to_cart_url();
    $ajax_class =   'add_to_cart_button product_type_simple';
    $text       =   '';
    $series     =   $product->get_attribute('pa_product-series');
    $content    =   get_the_excerpt();
    $price      =   $product->get_price_html();

Would like to show only first result of each series.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.