Get product variants with product id

HI,

In cscart, How to get product variants with product id ?.

In the cscart all product showing with product and product variants selectable , how to get products like product picker gets ?

Thanks

Hello

Want to get it in php code? Is it in the template? Do you want to find out what ID a product variant has? In table ?:products and ?:product_variation_group_products is informaction about it

Best regards
Robert

Hi,
Thanks for reply.

I want to get in php function. that i have all the parent product id’s but unable to get variant product as separate product.

Thanks

Try to use the fn_get_products function and add the variations_by_product_id parameter

Hi,

Thanks for your reply.

Used:
list($products, $search) = fn_get_products($params, Registry::get('settings.Appearance.products_per_page'), CART_LANGUAGE);

the variations_by_product_id is not working as expected.
the variations_by_product_id returns all the products but not passed product id

$product_ids = Array
(
    [0] => 3811
    [1] => 3872
    [2] => 3868
    [3] => 3886
    [4] => 3949
    [5] => 3950
    [6] => 4052
    [7] => 18568
    [8] => 18578
    [9] => 18617
    [10] => 18677
)

i have array of product ids when pass $params[‘p_id’] . i’m getting product with variants.
when i pass product ids as $params[‘p_ids’] and it is not working.

Thanks

Hello

Try writing queries directly into the database for the appropriate tables without using standard functions.

Best regards
Robert

1 Like

Hi!

Try adding the following parameters:

$params['include_child_variations'] = true;
$params['group_child_variations'] = false;