Tag Archives: Add

Custom Fields Multiselect Product Add Edit Pages Magento 2

This is a quite important demand when you want to use extra information on your pages which the default system does not include.

You can add custom fields with the help of UI Component.

Follow the below steps to create the module ‘PHPCodez_Customfield’

1) Declare a module.

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="PHPCodez_Customfield" setup_version="0.0.1" />
</config>

2) Register a module. Continue reading Custom Fields Multiselect Product Add Edit Pages Magento 2

Custom Fields Product Add Edit Pages Magento 2

This is a quite important demand when you want to use extra information on your pages which the default system does not include.

You can add custom fields with the help of UI Component.

Follow the below steps to create the module ‘PHPCodez_Customfield’

1) Declare a module.

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="PHPCodez_Customfield" setup_version="0.0.1" />
</config>

2) Register a module. Continue reading Custom Fields Product Add Edit Pages Magento 2

Add Navigation Menu Magento 2

You can add a new non catgory navigation menu as follows

1) Add the below code in layout XML

File : app\code\PHPcodez\Subscription\view\frontend\layout\default.xml

<?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="catalog.topnav">
 <block class="PHPCodez\Subscription\Block\Link" name="your.link">
 <arguments>
 <argument name="label" xsi:type="string">Subscription</argument>
 <argument name="path" xsi:type="string">subscription</argument>
 </arguments>
 </block>
 </referenceContainer>
 </body>
</page>

2) Define the block Link.php

File : app\code\PHPcodez\Subscription\Block\Link.php

<?php
 namespace PHPCodez\Subscription\Block;
 
 class Link extends \Magento\Framework\View\Element\Html\Link {

protected function _toHtml() {
 if (false != $this->getTemplate()) {
 return parent::_toHtml();
 }
 return '<li class="level0 "><a ' . $this->getLinkAttributes() . ' class="level-top" >' . $this->escapeHtml($this->getLabel()) . '</a></li>';
 }
 }

Add Top Link Magento 2

You can add a new top link as follows

1) Add the below code in layout XML

File : app\code\PHPcodez\Subscription\view\frontend\layout\default.xml

<?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>
 <referenceBlock name="header.links">
 <block class="PHPCodez\Subscription\Block\Link" name="add-new-header-link">
 <arguments>
 <argument name="label" xsi:type="string" translate="true">New Link</argument>
 <argument name="path" xsi:type="string" translate="true">new-link</argument>
 </arguments>
 </block>
 </referenceBlock>
 </body>
</page>

2) Define the block Link.php

File : app\code\PHPcodez\Subscription\Block\Link.php

<?php
 namespace PHPCodez\Subscription\Block;
class Link extends \Magento\Framework\View\Element\Html\Link {

protected function _toHtml() {
 if (false != $this->getTemplate()) {
 return parent::_toHtml();
 }
 return '<li class="level0 "><a ' . $this->getLinkAttributes() . ' class="level-top" >' . $this->escapeHtml($this->getLabel()) . '</a></li>';
 }
 }