תיקיות הבסיס למודול במגנטו


<?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="Anagal_NewModule" setup_version="1.0.0"/> </config>
לא לשכוח _vandor
\Magento\Framework\Component\ComponentRegistrar::register( \Magento\Framework\Component\ComponentRegistrar::MODULE, 'Learning_FirstUnit', __DIR__ );
לא לשכוח _vandor
php bin/magento module:status Anagal_NewNodule
Controller/Index/Index.php
<?php
namespace Anagal\NewModule\Controller\Index;
use Magento\Framework\App\Action\Context;
class Index extends \Magento\Framework\App\Action\Action
{
protected $_resultPageFactory;
public function __construct(Context $context,\Magento\Framework\View\Result\PageFactory $resultPageFactory)
{
$this->_resultPageFactory = $resultPageFactory;
parent::__construct($context);
}
public function execute()
{
$resultPage = $this->_resultPageFactory->create();
return $resultPage;
}
} 
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">
<router id="standard">
<route id="custommodule" frontName="custommodule">
<module name="Anagal_CustomModule"/>
</route>
</router>
</config>
id & frontName – אותיות קטנות
Block\Hello.php
שם הCLASS חייב להיות תואם לשם הקובץ .
<?php
namespace Anagal\CustomModule\Block;
class Hello extends \Magento\Framework\View\Element\Template{
public function getTitle(){
return 'Hello world!';
}
}
שם הקובץ חייב להיות תואם לשם הקלאס – עם אות גדולה
CustomModule\view\frontend\layout\custommodule_index_index.xml
שם הקובץ כשם הfronName ללא אותיות גדולות

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd" layout="1column">
<body>
<referenceContainer name="content">
<block class="Anagal\CustomModule\Block\Hello" name="anagal.hello" template="hello.phtml"/>
</referenceContainer>
</body>
</page>
[xlm/]
Anagal/NewModule/view/frontend/templates
<?php /* @var $block /Anagal/PopUP/Block/PopUP */ ?> <h2><?=$block->getTitle()?></h2>
block/ form.php – איזור לפונקציות
controller/index/index.php – יורש קלאס
etc/frontend/routes.xml – מגדיר כתובת
etc/module.xml – מגדיר את המודול
view/frontend/layout/new_index_index.xml – בונה את הבלוק
view/frontend/templates – form.phtml – תבנית תצוגה
registration.php – רישום מודול