What I'm trying to accomplish:

I have 2 types of products.

  1. Rental cars
  2. Rental companies (of those cars)

When comparing rental cars I want to show the rental cars attributes but also the attributes of its rental company.

So what I did was:

I added a dropdown attribute in rental cars with the rental companies so that I can make a connection between the two.

In logical terms it should be something like this: When rental car attribute X = 'Rent-A-Car', then display attributes of rental company 'Rent-A-Car'.

To be exact: The rental cars and the rental companies both have different attribute sets.

I believe this is doable but after days of trying I'm stuck. Anybody?


What I have pulled of myself so far is this:

        $product = Mage::getModel('catalog/product')->load($provider_id);
        $attributes = $product->getAttributes();

        foreach ($attributes as $attribute)
            if ($attribute->getIsVisibleOnFront())
                $attributeCode = $attribute->getAttributeCode();
                $label = $attribute->getFrontend()->getLabel($product);    
                $value = $attribute->getFrontend()->getValue($product);

                echo '<tr class="product-shop-row">';    
                echo '<th>' . $label . '</th>';

                foreach ($items as $_item)
                    echo '<td>' . $value . '</td>';    

                echo '</tr>';

I get the right attributes and the right attribute values but only from the first product in the list. The other compare products always have exactly the same values.

I believe I nead a sort of 'foreach product' but I don't know how :(

  • Create Separate attribute and then assign what attribute you need particular attribute set
    – Magento 2
    Commented Oct 27, 2015 at 19:05

2 Answers 2


It seems like you are on the right path. Where are you getting stuck?

Be sure to use ids instead of names. You can write an observer to add a "rental company" attribute each time one of those product types is added, but to start I would manually create one of these entries for each company.

Attribute "Rental Company" ("Name" => "Entity Id") "Hertz" => "1", "XYZ" => "23", "Enterprise" => "12"

The id should be the id of your rental car company product. Once you have that id, then you can load the company product and access it's attributes.


I think this is bad scheme, u should use category for rental cars company, but if u want make link u can use magento link like related products. After that u should change code compare page. U should add method which load product by link in block and after it add in template.

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.