12. May 2022 |

FacetWP reindex products automatically (simple solution with wp-cli + cron)

FacetWP had introduced WP-CLI interface which I was very much looking for. Just run wp facetwp index and reindex for the entire site will be created.

I just had a moment in one of my online stores where I saw that the index was last built 8 months ago. Now can add this line to WP All Import bash script and index will be built quickly every time. Or run it once day for example together with daily backup. I find it very convenient.

13. Apr 2022 |

Nginx stuff

/etc/hosts – lisa kirje

Confs

/etc/nginx/

/sites-available/ sinna tee conf.

Tee symlink sites-enabled kausta.

ln -s /etc/nginx/sites-available/teooria.conf /etc/nginx/sites-enabled/

sudo systemctl start nginx

5. Apr 2022 |

PHP useful commands

Version: php --version

php.ini

php -i | grep "Loaded Configuration File"

Install php extensions (as root)

apt install php7.4-apcu and then restart the apache server systemctl restart apache2

Apache2 conf is /ect/apache2/apache2.conf and files are /var/www/html
Apache local environment and rights and virtual host.
Apache hosts conf: /etc/apache2/sites-available/000-default.conf and sudo a2ensite local.akeneo.conf

 

1. Apr 2022 |

ps aux with grep

Very good ps aux overview can be found on Linode website.

grep stands for global regular expression print

grep by default is case sensitive. Add -i to make it case insensitive.

ps aux | grep -i "robert" | grep -i "vscode" – by such piping you can narrow down the search step by step.

If kill does not then add kill -9 <pid> (source).

history | grep “git commit” | grep “something”

Regular expressions in grep and on youtube basic Grep and Regex and the most useful DO guide

ps aux | grep -i "...be.t"  – simple pattern match.

ps aux | grep -P -i "^weekend"  – add -P to get perl compatible regular expressions to work

ps aux | grep -i '^weekend.*product' – lines that start with weekend and contains word product.

To see your proccesses then ps ux is enough.

13. Mar 2022 |

Russians are killing Ukrainians. 🇺🇦 Please help!

On February 24th 2022 Russians attacked the beautiful, free and democratic Ukraine. Without any reason. And started killing them.

Russians are killing everybody, without selection of their targets – civilians from infants to elderly people. Schools, hospitals, kindergardens, residential areas, nuclear power stations, everything. Russians are carpet bombing cities, also using banned artillery such as cluster bombs.

Please see how you can help Ukraine – supportukrainenow.org

To all the Russians, Belarussians, Armenians: You probably don’t have access to Twitter, Facebook, Reuters, BBCMeduza, Bellingcat, Washington Post etc. to get all the reliable information of what is going on in Ukraine and what your guys are up to there. Because it is all censored in your country. And this is can be the only explanation why you are so quiet and ignorant (to say the least).

Luckily, somehow you manage to get on my website. Therefore, I inform you that what you are currently doing in Ukraine is not good. Leave this country alone.  According to social surveys, you seem to support (and support) Putin and this war. Please, stop supporting this war (and Putin)! You have already lost around 50 000 men in this war (in just two weeks) and nobody likes you anyway.

22. Feb 2022 |

Magento REST API – Specified request cannot be processed and Class does not exist

Class \Vendor\ModuleName\Api\TestInterface does not exist

During development move things from local-src + symlink to app/code/{vendor}/{modulename} so that namespace and folder structure could match.

If you are using interfaces in your module then this is also true that you need to use full path reference in PHPdoc instead of use import and reference.

Both worked for me

Specified request cannot be processed

rest/V1/test/ – V in version needs to be capital letter (also in webapi.xml).

And just useful tip that you can extract interface out of existing class.

10. Feb 2022 |

Create a Magento plugin

Name plugin classes after what they do rather than after their target class.

First create plugin class and then configure it in di.xml. Plugin “name” in di.xml is module name that it is located at.

Plugin classes are located in Plugin folder within respective module.

After plugins execute after the target method. As a second argument after methods take return value of the target method.

10. Feb 2022 |

Create an empty Magento 2 module to vendor

Add repository section to Magento composer.json file with the following command. Path refers to the location of your module’s repository (or just local folder).

composer config repositories.robert-empty path ./local-src/robert-empty/

Then create composer.json, registration.php and etc/module.xml for the module. Manually, just copy from another module and update the content.

Then tell composer to install our module by referring to the package name defined in composer.json “name” field. This creates symlink with module repository to vendor folder.

composer require robert/module-empty

Then enable module. this command adds the module to app/etc/config.php file. List of modules to load and their load order. In database moduls are registered to setup_module table.

php bin/magento module:enable Robert_Empty && php bin/magento setup:upgrade

You can skip the first part of the command because setup:upgrade automatically enables new modules.

registration.php – makes the module visible.

etc/module.xml – lists depencencies in sequence node that have to be loaded first.