Thursday, December 29, 2016

Practical Magento 2: Creating a simple plugin

In Magento 1, when we wanted to override a specific method from the Core, we usually needed to rewrite Core class in our module.

Magento 2 introduced a new possibility for overriding core functionality without causing potential rewrite conflicts. It is called "Plugins".
Read more
, , ,

Friday, September 9, 2016

Practical Magento 2: Create a custom Module - minimal structure

There is no need to create a custom module structure from the scratch manually. Using this great tool helps to make creation process faster:

https://github.com/netz98/n98-magerun2

1. download and install n98-magerun2 as described on above link.

2. navigate to Magento root directory using terminal 3. running command:

$ n98-magerun2.phar dev:module:create
will display the following message with instructions about parameters that can be used for Module creation:

dev:module:create [-m|--minimal] [--add-blocks] [--add-helpers] [--add-models] [--add-setup] [--add-all] [-e|--enable] [--modman] [--add-readme] [--add-composer] [--author-name[="..."]] [--author-email[="..."]] [--description[="..."]] vendorNamespace moduleName
For minimal module structure, we can run:

 $ n98-magerun2.phar dev:module:create -m Apiworks Minimal
which will produce the following output:


Apiworks/Minimal/etc/module.xml
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nonamespaceschemalocation="urn:magento:framework:Module/etc/module.xsd">
    <module name="Apiworks_Minimal" setup_version="1.0.0">
        <sequence>
        </sequence>
    </module>
</config>
Apiworks/Minimal/registration.php
<?php

\Magento\Framework\Component\ComponentRegistrar::register(
    \Magento\Framework\Component\ComponentRegistrar::MODULE,
    'Apiworks_Minimal',
    __DIR__
);

Read more
, , ,

Tuesday, February 9, 2016

Installing xDebug on Mac OSX with AMPPS

Hi Dear reader!

You may be wondering why I am writing yet another article about xDebug installation on Mac OSX, but in fact, I am writing this more because of myself as I want to remember the easiest way on how to build and install custom xDebug without additional troubles in short time. (As I am sure I will forget it if not in written form :-p)

Usually when installing xDebug to make it work with AMPPS on Mac OSX, I downloaded Komodo Remote Debugging Package and selected version which fit my PHP version and put xdebug.so in my PHP modules directory.

Everything was just fine during the time, until the moment I started to play with Magento 2. I switched the AMPPS PHP version to 5.6 and installed Komodo xDebug as usual. But when tried to debug in PHPStorm, some weird errors appeared and debugging was practically impossible ....

Read more
, ,