How can I move breadcrumb before main title on Magento 2 - magento

I would like please your help. I am newbie on Magento 2 and still searching things. I would like to move breadcrumb before title (on category pages, product everywhere). I tried to change it on default.xml <move element="page.main.title" destination="page.top" after="breadcrumbs"/>
but with no luck.
Also i tried to do it from catalog_category_view.xml on vendor/magento/module-catalog/view/frontend/layout but no luck. Can anyone please guide me where can I find the order that is loading?
Can you please help? Thank you in advance

One should not call a title from a breadcrumbs template as this breaks independence.
Instead simply move breadcrumbs on top of main.content container.
<move element="breadcrumbs" destination="main.content" before="-"/>
You can find more info on this at Magento official documentation here : Magento 2 - Reorder recommendation units

Try this,
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<move element="page.main.title" destination="breadcrumbs" before="-" />
</body>
</page>

Related

Displaying Custom attribute in Product LIST PAGE, and Product Details page Under my Price attribute

I have created a custom attribute named cloth material, and i want to display it in my Product LIST PAGE, and Product Details page Under my Price.
Can someone suggest me how to achieve it? The current blog posts are out dated. I am using Magento 2.3.3.
I also need to do it programmatically. When i do it by selecting Display on store catalog, it displays it under more details.
First, create catalog_product_view.xml in your custom theme. (If already there, then modify this file)
app/design/frontend/Vendor/theme/Magento_Catalog/layout/catalog_product_view.xml
and add the below code in this file:
<?xml version="1.0" ?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceContainer name="product.info.main">
<block class="Magento\Catalog\Block\Product\View" name="cloth.material" template="Magento_Catalog::view/cloth_material.phtml" after="product.info.price"/>
</referenceContainer>
</body>
</page>
Now create cloth_material.phtml and add the below code in this file:
app/design/frontend/Vendor/theme/Magento_Catalog/templates/product/view/cloth_material.phtml
and add the below code in this file:
<?php
$_product = $block->getProduct();
// First method
$attribute_value = $_product->getResource()->getAttribute('your_attribute_code')->getFrontend()->getValue($_product);
// second method
$attribute_value = $_product->getAttributeText('your_attribute_code');
?>

In products list, show highest price instead of lowest

So, as the tile suggests when a user goes on the products list i want magento to show the HIGHEST price and not the lowest for the products with more prices (ex. a 1liter liquor bottle costs more than a 0.5l bottle, i want to show the price of the former).
I've already found the template file that gets involved with it, which is
/vendor/magento/module-configurable-product/view/base/templates/product/price/amount/default.phtml
and there i can see the $block->getDisplayValue() which i suppose is what returns me the price of the product, the problem i have is that i can't find where this getDisplayValue() is and then how to override it in my template so i can get it to return the highest price.
Hope my explanation was clear, thank you for your help.
go to
app/design/frontend/{{Vender_Namespace}}/{{Theme_Name}}/Magento_Catalog/layout/catalog_category_view.xml
Paste this
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="2columns-left" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceContainer name="content">
<referenceBlock name="category.products.list">
<action method="setDefaultDirection">
<argument name="dir" xsi:type="string">desc</argument>
</action>
</referenceBlock>
</referenceContainer>
<move element="category.view.container" destination="content" before="-"/>
</body>
</page>
and admin->configuration->catalog->Store Front->Product Listing Sort by Set price

Magento - Change Product Page Layout for only one Product in the define Layout Section

This is for sure a quicky, but nothing i found so far is working.
I would like to set a different product view for a choosen Product only. Not for a category. I tried to add this to the custom layout tab without any luck so far.
I tried any variantions of this:
<reference name="product.info">
<action method="setTemplate"><template>catalog/product/newview.phtml</template></action>
</reference>
But Magento will not read it!
Is there any easy solution to this ? Or maybe how i can get the template added to the layout dropdown in the Design Tab of the Product ? I mean the Tab where you can choose between 1-2 or 3 Columns Layout.
Thank you very much for your help. I am using Magento 1.9.1.
In your local.xml file put the following,
<layout>
...
<PRODUCT_86>
<reference name="root">
<action method="setTemplate"><template>catalog/product/newview.phtml</template></action>
</reference>
</PRODUCT_86>
...
</layout>
Here 86 is a product_id. Flush the cache and then check.
The Solution is quite easy: Make the new File readable by the Webserver.
For what its worth, maybe it helps someone.

How to add new layout via local.xml?

How can I add a new layout in magento using local.xml? I want it to appear in layouts list when I make new CMS page.
Layout in magento using local.xml
please go and follow this code.
http://www.codeboss.in/web-funda/2009/07/07/create-new-layout-in-magento/
Look at the very last block of code on this page. You can go into app/code/core/Mage/Page/etc/config.xml and add lines like this:
<TEMPLATE_LABEL module="page" translate="label">
<label>TEMPLATE NAME</label>
<template>page/TEMPLATE-FILENAME.phtml</template>
<layout_handle>page_HANDLE_NAME</layout_handle>
</TEMPLATE_LABEL>
replacing the capitalized words, e.g.
<home_format module="page" translate="label">
<label>Home Format</label>
<template>page/home-page.phtml</template>
<layout_handle>page_home_format</layout_handle>
</home_format>
Right before the end of the <page> ... </page> block of code.
Note: if you do it this way, you may not be able to upgrade Magento without losing your custom layout, as config.xml is a core file.

Adding a new reference block to Magento

I'm having some trouble getting a custom Reference block to work in Magento.
These are the steps I have taken:
Step 1
Created a new “Reference” block in page.xml
<block type="core/text_list" name="newreference" as="newreference"></block>
Step 2
Added a reference to this block in the place I want it to appear in the page (above the footer in 1column.phtml, 2columns-left.phtml, 2columns-right.phtml, 3columns.phtml)
<?php $this->getChildHtml('newreference'); ?>
Step 3
Added a reference to catalog.xml which tells Magento I want to output a template part (specialfooter.phtml) in the ‘newreference’ Reference block on Category pages
<reference name="newreference">
<block type="core/template" name="specialfooter" template="page/html/specialfooter.phtml"></block>
</reference>
Step 4
Created ‘specialfooter.phtml’ in the page/html/ directory with a simple paragraph block to test.
And nothing happens.
The steps I have taken fit with my understanding of how Reference blocks work, but I could be wrong. I'm struggling to find any documentation, official or otherwise, or any previous SO questions which sheds any light on the subject.
I'm using Magento ver. 1.7.0.2.
Any help would be much appreciated.
Don't you have forget a echo ? :
<?php echo $this->getChildHtml('newreference'); ?>
I was having the same problem and this seems to work for me.
This block in layout/page.xml
<block type="page/html/new_newreference" name="newreference" as="newreference" template="page/html/new/newreference.phtml"/>
Can be referenced in a page eg. 1column.phtml in the template/page folder using:
<?php echo $this->getChildHtml('newreference') ?>
Note the correlation between the "type" naming and "template" path and the "name" and "as" with the getChildHtml().
Using the same principle for a product page. This block in layout/catalog.xml
<block type="catalog/product_new" name="catalogreference" as="catalogreference" template="catalog/product/new/catalogreference.html"/>
Can be referenced in template/catalog/product/view.phtml using:
<?php echo $this->getChildHtml('catalogreference'); ?>
Note both these examples are folder specific
If you want a block to use with a widget. Add this block in the appropriate reference block eg "content" or "head" in the relevant xml file eg. page.xml or catalog.xml:
<block type="core/text_list" name="mywidgetblock" as="mywidgetblock">
<label>My widget Block</label>
</block>
NB: I don't understand the "type" declaration but it works?
In the admin panel CMS/Widget/Widget instance new or existing Layout Updates/ Block Reference find "My widget Block" from the drop down.
I'm new to Magento and it took a lot of trial and error to work this out so I hope it helps someone in the same situation.

Resources