I want to have a few layout types for products and control this via either the category and apply to child products or via individual products.
I want for example to change to a 2 column view however want blocks to automatically move about based on this decision rather than the extra need of placing layout xml within the layout update xml field. I am wondering how would be best to approach this.
Basically this is what I want to happen in layout xml but do not think there are any conditionals for layout type set on products within xml:
<move element="catalog.product.related" destination="sidebar.additional" before="-"/>
On top of this i would also like a lot more control for example if there are no related products then move crosssell products there instead.
I am thinking that I may need to remove these blocks from layouts and then add conditionals within the sidebar.phtml to decide weather the block needs to be shown and then populate with code like below:
<?php echo $this->getLayout() ->createBlock('Magento\Catalog\Pricing\Render', "product.price.final", [ 'data' => [ 'price_render' => 'product.price.render.default', 'price_type_code' => 'final_price', 'zone' => 'item_view' ] ] ) ->toHtml();?>