Code below gives me all associated products.


what should I do in order to get sorted valued based on price in ASC order ?

  • is this configurable attribute??
    – Amit Bera
    Commented Apr 25, 2015 at 7:24
  • Hey sourav, is this issue has been resolved
    – Amit Bera
    Commented Apr 29, 2015 at 6:13

4 Answers 4


This is sort of one way to do it.. But you'll need to make sure the price-as-string sorts alphanumerically the way you want. It may need some tweaking.

$sortedProducts = array();
foreach ($uesdProducts as $product) {
    $price = $product->getPrice();
    $sortedProducts[$price . '-' . $product->getId()] = $product;

Another is to use

$collection = $this->getProduct()->getTypeInstance()

Note: untested code.

  • 1
    Unless you have 2 products with the same price ;) Commented Apr 29, 2015 at 6:05


if($_product->getTypeId() == "configurable"):


    $simple_collection =  $conf->getUsedProductCollection()
                               ->setOrder('price', 'ASC');

    print_r($simple_collection);  // simple associated products collection


Hope this can be helpful:

public function getUsedProducts($requiredAttributeIds = null, $product = null)
    if (!$this->getProduct($product)->hasData($this->_usedProducts)) {
        if (is_null($requiredAttributeIds)
            and is_null($this->getProduct($product)->getData($this->_configurableAttributes))) {
            // If used products load before attributes, we will load attributes.

And in method getConfigurableAttributes you can see following:

public function getConfigurableAttributes($product = null)
    if (!$this->getProduct($product)->hasData($this->_configurableAttributes)) {
        $configurableAttributes = $this->getConfigurableAttributeCollection($product)
        $this->getProduct($product)->setData($this->_configurableAttributes, $configurableAttributes);
    return $this->getProduct($product)->getData($this->_configurableAttributes);

Rewrite this method and replace ->orderByPosition() with method you like

  • where rewrite can u tell , pls
    – mcoder
    Commented Apr 25, 2015 at 7:33
  • For debug purpose you can try fix here. If this start working - make model rewrite. Tell me what kind of sorting do you want to add? Sort by attribute_label?
    – zhartaunik
    Commented Apr 25, 2015 at 7:52
  • yeah i have attribute label size , i want to sort by size
    – mcoder
    Commented Apr 25, 2015 at 7:54
  • Sorry my solution is wrong. Its another type of sorting.
    – zhartaunik
    Commented Apr 25, 2015 at 8:09

You can this.That can be an alternative solution.

First get all child products ids


Filter the product collection by those childs ids and short by attribute

 $collection = Mage::getResourceModel('catalog/product_collection');
            ->addMinimalPrice() // optional for add minimal price to collection
            ->addFinalPrice() // optional for add minimal price to collection
            ->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes()) // add muitlple attribute to collection
  • not works.......also why u used addUrlRewrite
    – mcoder
    Commented Apr 25, 2015 at 7:41
  • mistake.... add addAttributeToSort for filter]
    – Amit Bera
    Commented Apr 25, 2015 at 7:44
  • script stops some error still
    – mcoder
    Commented Apr 25, 2015 at 7:48

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.