0

Hi I'm using below code to fetch associated product list

$associated_products = $_product->loadByAttribute('sku', $_product->getSku())->getTypeInstance()->getUsedProducts();

Is there any way to pass entity_id and fetch product belongs to that particular entity_id ?

1 Answer 1

2
$associated_products = $_product->load($_product->getId())->getTypeInstance()->getUsedProducts();

or if you already have the $_product entity, no need to load it again.
Try this:

$associated_products = $_product->getTypeInstance()->getUsedProducts();
5
  • does it not depend on wether you are using configurable or groupped products? (I was thinking about getUsedProducts() and getAssociatedProducts() Commented Jul 24, 2014 at 12:38
  • I thought it was only for configurable. I could be wrong.
    – Marius
    Commented Jul 24, 2014 at 12:42
  • @marius I'm getting the same associated product collections. I'm trying to get only one associated product by passing it's id. Commented Jul 24, 2014 at 12:44
  • @VinothPandiyan Then just user: $product = Mage::getModel('catalog/product')->load('your id here'); Is that what you need? Your question seams unclear.
    – Marius
    Commented Jul 24, 2014 at 12:46
  • @Marius I can confirm that getAssociatedProducts() => grouped products and getUsedProducts() => configurable products Commented Jul 24, 2014 at 12:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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