0
votes

Is there any way to show associated products (AP) SKUs on Magento product pages instead of the configurable product (CP) SKU?

At the moment, APs only show the CP SKU retrieved with <?php echo nl2br($_product->getSku()) ?>.

Our APs have a suffix appended depending on size, colour or volume etc e.g. a CP SKU MAS001 and an AP might be MAS0015L.

And we're currently on Magento ver. 1.5.1.0 with the Simple Configurable Product (SCP) extension installed.

2

2 Answers

1
votes

This should be able to accomplish what you are trying to accomplish

   /**
     * Load product by product id
     */
    $product = Mage::getModel('catalog/product')->load(YOUR_PRODUCT_ID);

    /**
     * Get child products id (only ids)
    $childIds = Mage::getModel('catalog/product_type_configurable')->getChildrenIds($product->getId());

    /**
     * Get children products (all associated children products data)
     */
    $childProducts = Mage::getModel('catalog/product_type_configurable')->getUsedProducts(null,$product);
0
votes

before you ask :) always look what is inside of your object by dumping it or inspecting it with debugger

<?php print_r($_product);?>

or if its too large and has many references then try to see object parameters only

<?php print_r(array_keys($_product));?>

Then you can inspect yourself what variables you can ask directly from object or what you need to query or extend your collections to get by default.