Showing posts with label Magento 2. Show all posts
Showing posts with label Magento 2. Show all posts

Install magento 2 extension

Manual installation process:
  1. Unzip extension package and upload them into Magento root directory.
  2. Run the following command in magento root folder
    • php bin/magneto setup:upgrade
    • php bin/magento setup:static-content:deploy

Mangento 2 admin menu description

http://www.magestore.com/magento-2-tutorial/how-to-create-admin-menu-in-magento-2/

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Backend:etc/menu.xsd">
    <menu>
     <add id="Magestore_CustomMenu::menu" title="Custom Menu" module="Magestore_CustomMenu" sortOrder="10" resource="Magestore_CustomMenu::create"/>
     <add id="Magestore_CustomMenu::menu_item" title="Manage Items" module="Magestore_CustomMenu" sortOrder="10" parent="Magestore_CustomMenu::menu" action="custommenu/create/index" resource="Magestore_CustomMenu::menu_item"/>
     <add id="Magestore_CustomMenu::menu_configuration" title="Setting" module="Magestore_CustomMenu" sortOrder="20" parent="Magestore_CustomMenu::menu" action="adminhtml/system_config/edit/section/menu" resource="Magestore_CustomMenu::menu_configuration"/>
    </menu>
</config>


Attributes:
  • id: identifier of this menu. It’s a unique string and has to follow this format: [Namespace_ModuleName]::[menu_name].
  • title: the text which displays on the menu bar.
  • module: name of module, format: [Namespace_ModuleName]
  • sortOrder: define the position of the menu, the lower value will display on top of the menu.
  • parent id of parent menu
  • action: URL which is redirected when click to the menu, format: [router_name]/[controller_name]/[action_name]
  • resource uses to defined ACL rule of the user role. Admin can use it to set permissions for any users.

Magento Commands

Installing the module

Now that the module is code-complete, run the following commands to install it:
  1. bin/magento module:status - This command shows a list of enabled/disabled modules.
  2. bin/magento module:enable MyCompany_ExampleAdminNewPage - If necessary, run this to enable the disabled module.
  3. bin/magento setup:upgrade - This command will properly register the module with Magento.
  4. bin/magento setup:di:compile - This command compiles classes used in dependency injections.
Mode Set:
php bin/magento deploy:mode:set developer
 php magento deploy:mode:set production

Extension remove from magento 2

To remove extension completely from Magento, you need to following things.
  1. Remove extension folder from app/code.
  2. Remove extension entry from config.php file avilable at app/etc folder of magento.
  3. Remove extension entry from "setup_module" table from database.
  4. Remove extensin block which you put either in CMS page or CMS block.
Now run the following commands:
php bin/magento cache:clean

php bin/magento indexer:reindex

php bin/magento setup:upgrade

php bin/magento setup:static-content:deploy

Magento 2 important location

Template Path Hints in Magento:
Store > Configuration > Advanced > Developer > Debug > Enabled Template Path Hints for Storefront > Yes

Security
Secret key 
Stores => Configuration => Advanced => Admin => Security => Add Secret Key to URLs

How to Call .phtml Template Only on Homepage in Magento 2

Create xml file name with /app/design/frontend/Vendor/theme/Magento_Cms/layout/cms_index_index.xml

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <referenceContainer name="page.top">
        <block class="Magento\Framework\View\Element\Template" name="home" template="Magento_Cms::html/home.phtml">
            <arguments>
                <argument name="section" xsi:type="string">homepage</argument>
                <argument name="position" xsi:type="number">0</argument>
            </arguments>
        </block>
    </referenceContainer>
</page>


Create .phtml file in
/app/design/frontend/Vendor/theme/Magento_Cms/templates/html/home.phtml

<?php echo $this->getLayout()->createBlock('Magento\Cms\Block\Block')->setBlockId('homepage-slider')->toHtml();?>


Magento 2 - How to call a custom phtml file in another phtml file, xml layout, static block and cms page?

http://stackoverflow.com/questions/34288366/magento-2-how-to-call-a-custom-phtml-file-in-another-phtml-file-xml-layout-s


Formula: 

{{block class="[BlockClassFullName]" template="[VendorName]_[ModuleName]::[YoutTemplateFile.location].phtml"}}