In this presentation, AResourcePool is introducing the reliable Magento 2 development services in India, USA and UK. If you are also looking the same services or hire Magento 2 developer India then don’t hesitate to contact us. We are well known web development company in Noida, Uttar Pradesh. We have delivered number of Magento projects to our clients. In these slides we have also provided some basic Magento 2 queries with its solutions. If you are dealing with such type of problems in Magento2 development cycle then it may help you. Feel free to contact us for more your queries.
1. Common Problems and Solutions of
Magento 2
AResourcePool
A Block, Sector 63, Noida,
Uttar Pradesh, India, 201307
Email id - info@aresourcepool.com
Website - www.aresourcepool.com
2.
3. Magento 2 is a champion among the most prevailing and
understood online business stages. Since Magento is a
totally incorporate stacked stage, it may seem, by all
accounts, to be difficult to manage. Nowadays, every
business is going to use this advanced technology to
make their business effectively. If you are the one among
them and wants to hire Magento 2 developer India then,
AResourcePool is the best company that provides
valuable or experienced developer for the same.
Well, if you want to learn something that you can do on
your own then, here you go:
4. • Well, if you want to learn something that you can do on your own then, here you
go:
• How to add header and footer to Magento 2?
• Ø For Header:
• Step 1: First, in the folder app/code create a custom module which should be
based on Magento 2 structure.
• Ex: Magento 2 root directory/app/code/Dckap/Newlink/
• Step 2: Now, in the below path create module.xml file which will describe your
Magento 2 extension.
Magento 2 root directory/app/code/Dckap/Newlink/etc/module.xml
<?xml version=“1.0”?>
<config xmlns:xsi=“http://www.w3.org/2001/XMLSchema-
instance”xsi:noNamespaceSchemaLocation=“../../../../../lib/internal/Magento/Fra
mework/Module/etc/module.xsd”>
<module name=“Dckap_Newlink” setup_version=“2.0.1”></module>
</config>
5. • Step 3: In the below path,now create routes.xml for your customlink.
• Magento 2 root directory/app/Dckap/Newlink/etc/frontend/routes.xml
• <?xml version=“1.0”?>
<config xmlns:xsi=“http://www.w3.org/2001/XMLSchema-
instance”xsi:noNamespaceSchemaLocation=“../../../../../../lib/internal/Magento/Framework/App/et
c/routes.xsd”>
<router id=“standard”>
<route id=“newlink” frontName=“newlink”>
<module name=“Dckap_Newlink”/>
</route>
</router>
</config>
• Step 4: In the below path,now made layout file for a custom header.
• Magento2 root directory/app/Dckap/Newlink/view/frontend/layout/header.xml
• <?xml version=“1.0”?>
<page xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance”
layout=“1column”xsi:noNamespaceSchemaLocation=“../../../../../../../lib/internal/Magento/Framew
ork/View/Layout/etc/page_configuration.xsd”>
<body>
<referenceBlock name=“header.links”>
<move element=“test-last” destination=“header.links”/>
<block class=“DckapNewlinkBlockHeader” name=“test-link” after=“my-account-link”/>
</referenceBlock>
</body>
</page>
6. • Step 5: In the below path of the layout file, create block file.
• Magento2 root directory/app/Dckap/Newlink/Block/Header.php
• <?php
namespace DckapNewlinkBlock;
class Header extends MagentoFrameworkViewElementHtmlLink
{
• protected $_template= ‘Dckap_Newlink::link.phtml’;
public function getHref()
{
return__( ‘testuser’);
}
public function getLabel()
{
return __(‘Test Link’);
}
}
?>
For third party URLs follow the above code.
• Step 6: In the below path, create template file that should be referred to the block file.
• Magento2 root directory/app/Dckap/Newlink/frontend/templates/link.phtml
• <li>
<a <?php echo $block->getLinkAttributes()?>><?php echo $block->escapeHtml($block-
>getLabel())?>
<?php echo($block->getCounter())? ‘<span>‘ . $block->escapeHtml($block->getCounter()).
‘</span>‘ : ”; ?>
</a>
</li>
7. • Step 7: When you are done with the above steps just run the below Magento 2 and its upgrade
command in the command prompt.
php bin/magentosetup:upgrade
• When you run this command after that clear the entire cache of Magento as well as also check the
extension as it is installed or not.
• Ø For Footer:
• Step 1: Now it’s time to create custom footer in Magento 2 link so, follow the abovefirst 3 steps
of header and put back the layout file with the code mentioned below:
• Magento2 root directory/app/Dckap/Newlink/view/frontend/layout/footer.xml
• <?xml version=“1.0”?>
<page xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance”
layout=“1column”xsi:noNamespaceSchemaLocation=“../../../../../../../lib/internal/Magento/Framew
ork/View/Layout/etc/page_configuration.xsd”>
<page>
<referenceBlock name=“footer_links”>
<block class=“MagentoFrameworkViewElementHtmlLinkCurrent” name=“2custom-link”>
<arguments>
<argument name=“label” xsi:type=“string”>Footer Link</argument>
<argument name=“path” xsi:type=“string”>testuser</argument>
</arguments>
</block>
</referenceBlock>
</page>
8. • Step 2. You can get the argument value by following two steps:
• Use block file. This is specially used by header.
• Specify argument value in layout file. This is specially used by footer.
• Step 3: Follow the 7th step mention in the header.
• By using these steps you can simply add the header and footer in the Magento 2.
• How to improve the security of Magento 2 store?
• The greatest worry of each online business is the security of their online store. So,
follow the best tips for improving your Magento 2 security.
• Latest Magento Version is best:Commonly, you will be informed that the latest
isn't the best.. Magento reliably gets refreshed at a decent pace. Resulting
Magento adaptations fix security issues of the previous ones. Subsequently, it is
basic to remain educated about the most recent Magento variant.
9. • Utilize Two-Factor Authentication: In this age, a protected Magento secret
key is unfortunately insufficient. There are a couple of expansions that
convey two-factor validation with the goal that you don't need to stress
over secret word related Magento security hazards any longer.
• Custom path for the Admin Panel:I t is easy for programmers to jump on
to your administrator sign in page and begin speculating passwords. You
can keep this by/administrator with a tweaked term. It likewise keeps
programmers from jumping on to your administrator login page regardless
of whether they some way or another get hold of your secret phrase.
• Pick a high caliber of security Hosting supplier: You ought to pick an
authentic facilitating supplier for your site and getting some information
about security before choosing to explore to this facilitating. You should
likewise guarantee this facilitating supplier claim a safe programming
improvement which is reasonable for your site. This is critical on the
grounds that you will claim a high-security site with the supporting from
high-security facilitating supplier.
10. • Secure condition:
• With the safe condition, your Magento 2 site absolutely runs easily.
Along these lines, you ought to secure your condition cautiously.
The following are a few answers for a sheltered situation:
• Update all the product and apply fixes as when suggested
• Approach the facilitating supplier for erasing all the pointless
programming on the server
• Simply utilize secure interchanges convention like SSH, SFTP or
HTTPS to oversee records
• Utilize a secret key as most secure as you can and transform it
occasionally
• Fix any issues which are accounted for programming parts utilized
by your Magento establishment as you see the alert
11. • Improve Magento 2 security: Magento 2 is the most recent rendition from
Magento with the best security fixes so you don't stress over Magento 2
establishment. Be that as it may, you ought to improve the security by designing
the security for setup settings, secret phrase and continuous support.
Furthermore, some different things you ought to do are:
• Supplanting the default "administrator" or the regularly utilized "backend" by a
one of a kind, custom Admin URL
• Blocking access to any improvement, arranging or testing frameworks
• Utilizing a right record authorizations
• Try not to be shown a good time: Having a cautious thought before choosing to
introduce any expansions or snap on an advertisement.
• Especially get ready for all of sudden issues
• Improve your recuperation congruity plan
• Test the reinforcement routinely to guarantee that it very well may be
reestablished
• Work with your facilitating supplier to make an expert database reinforcement
arrangement
12. • Check for indications of attack:
• You should check for indications of assault routinely. A standout amongst the most
famous signs is that your framework isn't quickly fixed after a noteworthy security
break. For this situation, you can do others like:
•
Check the Admin activities Log for suspicious action
Utilize programmed log survey devices
Audit server logs for suspicious by asking the co-task from your facilitating supplier
• Counteract MySQL Injection:
• Despite the fact that Magento gives fantastic help to outflank any MySQL infusion
assaults with its more up to date forms and fixes, it isn't generally a perfect way to
deal with depend just on them. We propose that you include web application
firewalls, for example, NAXSI to protect your website and your clients.
13. • Complete a Magento Security Review:
• Magento engineers are not really security specialists. Truly, huge numbers of them
are great at coding, however just a couple of know the complexities of Magento
site security. That is the reason once (or maybe, twice) a year, you ought to get
your site examined for evident escape clauses and security inadequacies. On the
off chance that effectively done, these surveys help in further solidifying of your
Magento safety efforts.
• Admin url returning 404 error in Magento 2?
• You can get an error while downloading Magento 2. The error that you can get is
404 Error Page Not Found. Well if you get the error then, don't worry as there is
some solution.
Mainly, there are 4 reasons why 404 Error Page Not Found is:
• Reason 1: After installing/upgrading
• Reason 2: Fresh Install On Ubuntu/Centos/Debian
• Reason 3: Page 403 Forbidden errors
• Reason 4: Messy page, no style
14. • SOLUTION 1: Flush Magento Cache with command line:
• php bin/magentocache:clean
rm -rf var/cache/*
rm -rf var/generation/*
• Solution 2:
• Enable Rewrite mode
sudo a2enmod rewrite
• Configure apache
• For Ubuntu / Debian edit the file /etc/apache2/apache2.conf. To edit this file run command
• sudo vi /etc/apache2/apache2.conf
• Modify from:
• <Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
to
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
Then restart apache
sudo service apache2 restart
or
sudo /etc/init.d/apache2 restart
15. • Solution 3:
• Open apache2.conf file
• For Ubuntu, the file /etc/apache2/apache2.conf. To edit this file run command
• sudo vi /etc/apache2/apache2.conf
• Update like this:
• <Directory /var/www/>
• Options Indexes FollowSymLinksMultiViews
• AllowOverride All
• Order allow,deny
• Allow from all
• </Directory>
• Create a custom frontend view in Magento 2:
• There are five steps involved in creating a fronted view in Magento 2. So, here have a look at those steps:
• Step 1: Register CustomView module
• Register a new custom view module with the help of Namespace Cloudways. For that, you can go to
app/code/Cloudways/Newmodule and create a new registration.php file.
• Step 2: Create a Controller action
• Just make the file Index.php file as go to app/code/Cloudways/Newmodule/Controller/Index. It would be the
controller action.
16. • Step 3: Create a Layout file
• For creating a layout file, use a file inside the module folder which is
named after the module structure. The general naming style
isRouterName_ControllerName_ActionName.xml. So in this case, create
the file newmodule_index_index.xml in
app/code/Cloudways/Newmodule/view/frontend/layout directory.
• Step 4: Create a Block file
• Now, to create a block file of the module follow this direction. Block file
has many logical functions which will be used in the file of the template.
For creating the block file type code
app/code/Cloudways/Newmodule/Block and name it Newmodule.php.
• Step 5: Create a Template file
• File of the template will be stored as the new module .phtml which will be
locate in and app/code/Cloudways/Newmodule/view/frontend/templates.
17. • Disable add to cart button in Magento 2
• In order to disable the add to cart button, one must have to build a system
module. As there is no good option to edit the files as well as do the
editing. When you get done with the creation of the module just build
InstallData.php file in app/code/Magenticians/Mymodule/Setup. You have
to add some code in it like:
• <?php
• namespace MagenticiansMymoduleSetup;
• use MagentoEavSetupEavSetup;
• use MagentoEavSetupEavSetupFactory;
• use MagentoFrameworkSetupInstallDataInterface;
• use MagentoFrameworkSetupModuleContextInterface;
• use MagentoFrameworkSetupModuleDataSetupInterface;
• use MagentoCatalogSetupCategorySetupFactory;
• use MagentoEavModelEntityAttributeSetFactory as
AttributeSetFactory;
• class InstallData implements InstallDataInterface
19. • How to add custom admin menu in Magento 2?
• Step 1: Build a new registration.php file in
• Magento2Root/app/code/Cloudways/Adminmenu/ and add the code below to it:
• <?php
• MagentoFrameworkComponentComponentRegistrar::register(
• MagentoFrameworkComponentComponentRegistrar::MODULE,
• 'Cloudways_Adminmenu',
• __DIR__
• );
• Now to declare the module, create a module.xml file in
Cloudways/Adminmenu/etc/ with the following code:
• <?xml version="1.0"?>
• <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.x
sd">
• <module name="Cloudways_Adminmenu" setup_version="1.0.0"></module>
• </config>
• File menu.xml will handled the admin menu. This file holds of <config>, <menu>
and <add> elements. <menu> constituent may have of multiple <add> elements as
well.
20. • Create a new file menu.xml in Cloudways/Adminmenu/etc/adminhtml/ and add the following
contentto it:
• <?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="Cloudways_Adminmenu::first_level_demo"
• title="CloudwaysAdmin Menu"
• module="Cloudways_Adminmenu"
• sortOrder="20"
• resource="Magento_Backend::content"
• />
• <add id="Cloudways_Adminmenu::second_level_demo"
• title="Sub Menu"
• module="Cloudways_Adminmenu"
• sortOrder="1"
• action="menuitem/index/index"
• parent="Cloudways_Adminmenu::first_level_demo"
• resource="Magento_Backend::content"
• />
• </menu>
• </config>
21. • As should be obvious the menu.xml record, we have characterized two
<add> component with characteristics. Initial one is utilized for first
dimension menu and the second one is for the second dimension menu
with extra activities and parent properties.
•
• Here is a clarification of each characteristic:
• id – one of a kind identifier
• title – title of the menu that will appear in the administrator
• module – shows the module
• sortOrder – organize the spot of menu
• asset – the standard to distinguish which administrator client see and
access this menu
• activity – connection to the predetermined administrator controller
• parent – characterizes on which first dimension menu it depends
• At long last, everything is prepared that will include custom administrator
menu in Magento 2 Admin Panel. To empower and initiate the custom
module, run the accompanying CLI directions:
22. • rm -rf var/di/* var/generation/* var/cache/* var/log/*
var/page_cache/*
• php bin/magentocache:clean
• php bin/magentocache:flush
• php bin/magentosetup:upgrade
• php bin/magentosetup:di:compile
• php bin/magentoindexer:reindex
• In the end, it will look something like this:
• Magento 2 is very vast topic which has so much new to
learn or modify. If you want such kind of service
then, hire Magento 2 developer
India from Aresourcepool. The developer from the
company will help you with the best.
23. AResourcePool
Noida, India (Research & Head Office)
A Block, Sector 63, Noida, Uttar Pradesh,
India, 201307
Mobile No: +91-9711621550
Email id- info@aresourcepool.com
Website - www.aresourcepool.com