First of all, write the code in the respective phtml file and then copy the content to the backend by creating a block in CONTENT-> BLOCK -> NEW BLOCK then call the block in the respective HTML file using the following code <?php echo $this->getLayout() ->createBlock(‘Magento\Cms\Block\Block’) ->setBlockId(‘nb_about_us’) ->toHtml(); ?>
Category: Magento
How to add new blocks to a page
First of all, write the code in the respective phtml file and then copy the content to the backend by creating a block in CONTENT-> BLOCK -> NEW BLOCK then call the block in the respective HTML file using the following code <?php echo $this->getLayout() ->createBlock(‘Magento\Cms\Block\Block’) ->setBlockId(‘block name’) ->toHtml(); ?>
How to use different layouts for different category levels.
Sometimes we need to use different layouts or structures based on category levels. For this, we can able to use different layouts based on different category levels. Solution: To create different layout structures for different categories develop layout files under the Magento_Catalog. One option would be adding a layout handle based on the category depth… Continue reading How to use different layouts for different category levels.
Adding custom classes to Magento shipping page address fields
Create plugin after Attribute merge Plugin to add custom classes to shipping address page In your module create MODULE/NAME/etc/di.xml Then in \MODULE\NAME\Model\Plugin create a php file AttributeMergerPlugin.php Example: <?php namespace JJ\Catalog\Plugin\Checkout\Block; class AttributeMergerPlugina { public function afterMerge(\Magento\Checkout\Block\Checkout\AttributeMerger $subject, $result) { if (array_key_exists(‘checkout-step-shipping’, $result)) { $result[‘checkout-step-shipping’][‘additionalClasses’] = ‘checkout-shipping-address’; } if (array_key_exists(‘telephone’, $result)) { $result[‘telephone’][‘additionalClasses’] = ‘mobile-number-validation’; ]; return… Continue reading Adding custom classes to Magento shipping page address fields
Magento Adding custom validations-(Phone Number)
Magento doesn’t have any validation for a ten digit mobile number validation.For getting this there are some many ways.This method is taking about overriding the inbuilt validation rules. For this we have to Create a custom module for the theme , for reference: https://devdocs.magento.com/guides/v2.3/frontend-dev-guide/themes/theme-create.html after that inside the create path Magento Ui >Magento_Ui/web/js/lib/validation/rules.js Here we… Continue reading Magento Adding custom validations-(Phone Number)
Remove Category Image on top of Category Page and Sub-Category Page
You can remove the image via layout in your custom theme. For example, in your custom theme: app/design/frontend/Vendor/Theme/Magento_Catalog/layout/catalog_category_view.xml – The layout – Template
How to set multiple currencies in one storefront?
To setup multiple currency on Magento 2 follow this step: Setup currency: Move to menu Stores >> Configuration. Under GENERAL tab you will find sub menu Currency Setup. Setup Currency Options with what you need and click Save Config. 2.Setup currency rates: Move menu to Stores >> Currency Rates. Set value for all parameters and hit Saves Currency Rates
How to get all children product from parent configurable product in magento2
You have to just keep below code inside block file and call function inside your template,
Correct Way to get Order items in magento 2
This is how the different methods to get items from an order work: This is how the different methods to get items from an order work: getItems(): returns array of items from loaded order item collection getAllItems(): returns array of all items that are not marked as deleted getAllVisibleItems(): returns array of all items that… Continue reading Correct Way to get Order items in magento 2
How to get step name on checkout page in magento 2?
You can use the Magento_Checkout/js/view/progress-bar component or Magento_Checkout/js/model/step-navigator componen (used by progress-bar) inside your custom block template/component. Using progress-bar: Using step-navigator: or: