0

For some products (same category) we need a different layout. How can I get this new layout only for those products. I know where to find the view.phtml and to adjust is, but how can you select the right layout in the backend for only that specific product?

When I change the local.xml then it will be changed for every product.

Do I have to make a whole new page layout? And how further?

0

Option 1: use local.xml

You can target specific products or categories from local.xml.

For product page, there are two additional layout handles:

  • <PRODUCT_TYPE_[type_id]>
  • <PRODUCT_[product_id]>

For categories:

  • <CATEGORY_[category_id]>

Option 2: admin backend

Go to admin product/category edit page and add your layout updates do Custom Layout Updates section.

Edit: (not tested)

Add your layout updates to local xml - with an own handle name ... and in layout update section just add <update handle="my_layout_handle"/> Maybe usefull if you want to apply your layout on several pages.

Option 3: custom layout handle

If you want to apply layouts for different products or on special conditions, you can add you own layout handles ... something like this:

public function addPreviewHandle(Varien_Event_Observer $observer)
{
    $action = $observer->getAction();
    if ($action->getFullActionName() === 'catalog_product_view'
        && $action->getRequest()->getParam('preview') === 'true') {
        $update = $observer->getEvent()->getLayout()->getUpdate();
        $update->addHandle('my_admin_product_preview');
    }
}

and layout update ...

<layout version="0.0.1">
    <my_admin_product_preview>
        ...
    </my_admin_product_preview> 
</layout>

Update:

When I make a specific view.phtml for only this category, How can I select the right product view for this different layout.

Either in layout XML

<CATEGORY_123>
    <reference name="product.info">
        <action method="setTemplate">
            <template>path/to/file.phtml</template>
        </action>
    </reference>
</CATEGORY_123>

Or in backend settings for this category

<reference name="product.info">
    <action method="setTemplate">
        <template>path/to/file.phtml</template>
    </action>
</reference>
  • thanks for your respons! Option 2 i now how to select a different layout now, but I don't know how to select a different product view. Maybe I asked it wrong. The way the productpage is shown has to get a different layout/look. Some details has to be removed and others to be added, Like price, description, photo etc. When I make a specific view.phtml for only this category, How can I select the right product view for this different layout. – esther Nov 19 '18 at 8:30
  • @esther updated answer. was this what you are looking for? – sv3n Dec 4 '18 at 17:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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