Thursday, 29 March 2018

How to Remove product details apge Email to

How to Remove product details apge Email to

app/design/frontend/webguru/mifitness/Magento_Catalog/layout/catalog_product_view.xml

<referenceBlock name="product.info.mailto" remove="true" />

How to move product description after product options in Magento2

How to move product description after product options in Magento2

<move element="product.info.description" destination="product.info.main" before="product.info"/>

Tuesday, 6 March 2018

How to remove breadcrumbs from category page in Magento 2

How to remove breadcrumbs from category page in Magento 2

app/design/frontend/Vendor/Theme/Magento_Catalog/layout/default.xml

---------------------------------------------------
<?xml version="1.0"?>
<!--
/**
 * Copyright © 2013-2017 Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceBlock name="breadcrumbs" remove="true" />
   </body>
</page>
----------------------------------------------
For remove toolbar
<referenceBlock name="product_list_toolbar" display="false" />

Sunday, 4 March 2018

How To add JS file in frontend for all pages in magento 2

How To add JS file in frontend for all pages in magento 2
requirejs-config.js under :- /app/design/frontend/your_vendor/your_theme/

To load a custom main.js file on all pages (in the RequireJS-way) this is a good way:
1) Create main.js
Create main.js within the theme folder
<theme_dir>/web/js/main.js
with this content:-------------

define([
  "jquery"
],
function($) {
  "use strict";

  // Here your custom code...
  console.log('Hola');

});

2) Declare main.js with a requirejs-config.js file
Create a requirejs-config.js file within the theme folder:

<theme_dir>/requirejs-config.js

with this content:

var config = {

  // When load 'requirejs' always load the following files also
  deps: [
    "js/main"
  ]

};


--------------------------------------------
app/code/your_vendor/your_theme/Magento_Theme/layout/default_head_blocks.xml

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <head>
        <!-- Add local resources -->
        <css src="css/my-styles.css"/>

        <!-- The following two ways to add local JavaScript files are equal -->
        <script src="Magento_Catalog::js/sample1.js"/>
        <link src="js/sample.js"/>

        <!-- Add external resources -->
        <css src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap-theme.min.css" src_type="url" />
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js" src_type="url" />
        <link src="http://fonts.googleapis.com/css?family=Montserrat" src_type="url" />
    </head>
</page>

Wednesday, 21 February 2018

How can I add a custom block to the products page in Magento 2?

In app/code/Namespace/Modulename/Magento_Catalog/layout/catalog_product_view.xml add like below code.
 You can use your required referenceContainer

 <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceContainer name="alert.urls">
            <block class="Magento\Catalog\Block\Product\View" name="textblock" as="textblock" before="-" template="product/view/stockavilable.phtml" />
        </referenceContainer>
    </body>
</page>

Tuesday, 20 February 2018

How to assign products in category by programmability in magento

How to assign products in category by programmability in magento

To Add Product to Category:
Mage::getSingleton('catalog/category_api')->assignProduct($category->getId(),$p‌​roduct->getId());

To Remove product from category:
Mage::getSingleton('catalog/category_api')->removeProduct($category->getId(),$p‌​roduct->getId());

Saturday, 10 February 2018

How to list products in descending order in magento 1.x?

How to list products in descending order?

 <reference name="product_list">
            <action method="setDefaultDirection"><dir>desc</dir></action>
  </reference>