News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Loop through child products in category view

Started by Kuubs, February 07, 2020, 08:50:21 AM

Previous topic - Next topic

Kuubs

Hello,

I want to loop through my child products on the category page to get all the product_s_desc of the child products to display on the category page. How can I do this?

Is there some sort of function to get the data of the child products? I don't see anything in the $this->product array.

Studio 42


In product model ou have getUncategorizedChildren

$productModel = VmModel::getModel ('product');
$productModel->setId($product->virtuemart_product_id);
$uncatChildren = $productModel->getUncategorizedChildren(false);
if($uncatChildren){
foreach ($uncatChildren as $k => $child) {
$child = $productModel->getProduct((int)$child,true);
//you can acces to this $child  here
}
}

PRO

Quote from: Huubs on February 07, 2020, 08:50:21 AM
Hello,

I want to loop through my child products on the category page to get all the product_s_desc of the child products to display on the category page. How can I do this?

Is there some sort of function to get the data of the child products? I don't see anything in the $this->product array.


Child products that are displayed?
Or are you referring to the children on a parent that is displayed?


Kuubs

#3
Quote from: PRO on February 07, 2020, 17:06:05 PM
Quote from: Huubs on February 07, 2020, 08:50:21 AM
Hello,

I want to loop through my child products on the category page to get all the product_s_desc of the child products to display on the category page. How can I do this?

Is there some sort of function to get the data of the child products? I don't see anything in the $this->product array.


Child products that are displayed?
Or are you referring to the children on a parent that is displayed?

No the child products don't have categoires so the parent is only visible in the category for a clean shop. Now you can select the child products via a custom field, but I want to show certain data from the child productts on the category page

Quote from: Studio 42 on February 07, 2020, 16:39:09 PM

In product model ou have getUncategorizedChildren

$productModel = VmModel::getModel ('product');
$productModel->setId($product->virtuemart_product_id);
$uncatChildren = $productModel->getUncategorizedChildren(false);
if($uncatChildren){
foreach ($uncatChildren as $k => $child) {
$child = $productModel->getProduct((int)$child,true);
//you can acces to this $child  here
}
}


Thanks im gonna check it out that works!