0

I need to be able to filter a product collection for grouped products that is not the issue i also need to filter the collection by grouped products that have a specific number of child products.

Any help would be appreciated been wrapping my brain arround this one today.

Regards

1

i know about the relationship just trying to filter the relationship was the problem just decided on this approach.

public function hasChildCount($count, $catid)
        {
            $products = Mage::getModel('catalog/category')->load($catid)
                ->getProductCollection()
                ->addAttributeToFilter('type_id', array('eq' => 'grouped'));

            foreach ($products as $product) {
                $associatedProducts = $product->getTypeInstance(true)->getAssociatedProducts($product);
                $countProducts = count($associatedProducts);
                if(($count == 5 &&  $count >= $countProducts ))
                {
                    $ids[] = $product->getId();
                }elseif($count == $countProducts)
                {
                    $ids[] = $product->getId();
                }
                // Do something with $associatedProducts
            }

            return $ids;
        }

and then in the actual attribute to filter

 array('entity_id'=>array('in',$idsIn ));
0

Magento is save the relation between grouped product ant it related child products at database table catalog_product_link.

In this table,there relation is build with field( link_type_id=3)

Now,if i add new column which is add count of child product then it would properly work

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.