Magento 2 useful commands

update DB command

 sudo php -d memory_limit=-1 bin/magento setup:upgrade
 sudo php -d memory_limit=-1  bin/magento setup:db-schema:upgrade 

//deploy static content

sudo php -d memory_limit=-1 bin/magento setup:static-content:deploy -f

// change permissions

sudo chmod -R 777 var pub 

//deply setup content

sudo php -d memory_limit=-1 bin/magento setup:di:compile

//enable/disable module

sudo bin/magento module:disable --clear-static-content Component_Name 

Points to keep in mind while developing custom form in Magento 2 module on admin end.

Two things keep in mind


1) Form action could be defined as

<?php echo $this-&gt;getUrl("pilot_smile/options/save"); ?>;
2) Do not forget to add form_key else you would be going to waste your several hours on finding the dashboard redirection issue on form submission.
<input name="form_key" type="hidden" value="<?php echo $block->getFormKey()?>" />;

 

 

UI Component Listing And Not registered handle in Magento2

If you face below error in your Magento 2 custom module.

Not registered handle [namespace]_[module]_team_index_data_source

There is one reason for above error is that you are missing di.xml file from [namespace]_[module]/etc/ folder

Copy the following code into di.xml file and place it in root of the etc folder of your module. Don’t forget to change the namespace and module name according to your module in the code.


<type name="Magento\Framework\View\Element\UiComponent\DataProvider\CollectionFactory">
<arguments>
<argument name="collections" xsi:type="array">
...
<item name="[namespace]_[module]_team_index_data_source" xsi:type="string">[Namespace]\[Module]\Model\ResourceModel\Team\Collection</item>
...
</argument>
</arguments>
</type>

Happy coding 🙂