Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Configurable product - Showing parent info on child product ? 
 
leruss
Jr. Member
 
Total Posts:  21
Joined:  2008-08-13
 

Hi there,

I’m still struggling with the configurable products and now I’m a little stuck on this problem.

I modified the configurable product template to show all the child products in a dropdown box to fit our needs. When selecting a product in this list, you are automaticaly redirected to the child product.

But what you see then is the attributes, descriptions, photos, etc… of the child product, and instead I want to show the parent (configurable) product informations in this place.

So the question is how can I get the parent product information when I’m on a child product ?

Thanks,

Manu.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Perrine L
Jr. Member
 
Total Posts:  22
Joined:  2009-05-11
France
 

Hello,

I need to access to the “parent” configurable product of a child product, after this :

$product Mage::getModel('catalog/product')->load($productId);

With which method can we do it ?

 
Magento Community Magento Community
Magento Community
Magento Community
 
leruss
Jr. Member
 
Total Posts:  21
Joined:  2008-08-13
 

Hi Perrine,

I use custom attributes on all my products to make a link between the parent (configurable) product and his childs (simple) products :

- Attribute parent_enfant which determine the nature of the product
- Attribute ref_unique that contains the parent (configurable) product SKU.

For example :
Parent product (configurable)
SKU : produitparent
parent_enfant : Parent
ref_unique : produitparent

Child product
SKU : produitenfant
parent_enfant : Enfant
ref_unique : produitparent

Then in my catalog/product/view.phtml template :

// Get the current product info
$_product $this->getProduct();

// Value of the parent_enfant attribute
$parent_ou_enfant $_product->getResource()->getAttribute('parent_enfant')->getFrontend()->getValue($_product);

// Check if product is a child
if ($parent_ou_enfant == "Enfant"{
    
    
// Get the parent product SKU
    
$skuparent $_product->getResource()->getAttribute('ref_unique')->getFrontend()->getValue($_product);
    
    
// Get the parent product ID
    
$idparent Mage::getModel('catalog/product')->getIdBySku($skuparent);
    
    
// Load the parent product model
    
$prodparent Mage::getModel('catalog/product')->load($idparent);
    
    
// Use example : Check if the child has a description and short description, if not then use the parent's description and short description
    
if ($description == "" || $description == " "{ $description $prodparent->getDescription(); }
    
if ($shortdescription == "" || $shortdescription == " "{ $shortdescription $prodparent->getShortDescription(); }
}

Maybe there’s a easier way to do this, but when I developed my site last year it’s the solution I found to link my products, and it works ^^

Hope this helps, PM me if you need more explanations, we use extensively the configurable products on our store.

(You can PM me in French if you want rasberry)

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top