Magento 2 API usage

Recently, in my day to day activities I had to figure something out with the Magento API. Magento 2 that is. Which is a beast, to say the least (hey! just made a rhyme!).

Anyway, I posted the question  I had at the time in the Magento dedicated subsite on StackExchage in the hope that someone from the well-formed community can give me an answer. Unfortunately nothing yet (posted about a week ago, at the time of writing this). Continue reading

Oh, recruiters…

Part of having an account on LinkedIn is getting tons of emails from recruiters. If  the advertised roles are relevant to you or not, that’s another question. If I think about it actually – is there another benefit of having a LinkedIn account?!

From time to time though, I get real gems like the following: Continue reading

Media Centre Automation

Today, being Saturday and having a bit of spare time on my hands, seemed like a brilliant idea to have a go at furthering my “skills” with the Amazon Alexa gadget. This time, I wanted to see how an integration between Alexa and the KODI media centre would be like. In simple terms, the workflow is kinda like this:

  • you tell Alexa a command
  • Alexa calls your “skill” built specifically for this occasion
  • this “skill” recognises your “intent” and communicates with an Amazon Lambda function that you have to build
  • the Lambda function sends a message to the webserver you built in your home and faces both the “outside world” and your intranet
  • the webserver interprets the Lambda signal and instructs the media centre to do your bidding
  • done!

Again, as I said, that’s in simple terms. The reality was a bit more complicated, but really exciting, I have to say.

Step I: The Raspberry PI Webserver

Yesterday evening, I dusted my Raspberry PI which was powered of since… a few years ago 🙁 Installed a new, fresh OS, went with the lite version of Raspbian, which is based on Debian Jessie. No graphical interface, no window managers, just a “hardcore” CLI. Some time later, after the OS installation, got nginx as a webserver and PHP5 (the fpm “flavour”) for the scripting interpreter up and running. The conf file for the nginx server looks like this:

server {
	listen 80 default_server;
	listen [::]:80 default_server;

	root /var/www/html/xbmc/public;

	index index.php;

	server_name _;

	location / {
		#try_files $uri $uri/ =404;
		try_files $uri $uri/ /index.php$is_args$args;
	}

	location ~ \.php$ {
		include snippets/fastcgi-php.conf;
    		fastcgi_pass unix:/var/run/php5-fpm.sock;
    		fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    		include fastcgi_params;
	}

	# deny access to .htaccess files, if Apache's document root
	# concurs with nginx's one
	#
	location ~ /\.ht {
		deny all;
	}
}

Note: I later added a htpasswd protection, since the webserver is web-accessible. Once that was out of the way, it was time to proceed to the next step:

Step II: The Web Application

Ok, the webserver is up and running, time to build a web-app that will allow me to send control messages to the KODI media centre. Now, KODI’s got a decent API that you can use, an easily enough, it’s JSON driven, so pretty simple to use. Since this is just for testing/playing, I didn’t bother to enable basic http-auth in KODI for this, so I can easily send messages to it. Right! Since lately in the office the platform Laravel was mentioned, I thought it’ll be good to step out of my “comfort zone” that is Magento and try different things. Easy enough, “composed” laravel and created a new project. For IDE, I am using PhpStorm – is there anything better, anyway?! 🙂 No expert in laravel, but a couple of hours later was having a functional web application that was sending KODI pretty much the basic remote control signals: arrows (left, right, up & down), the “select” key, volume 1-100 in increments of ten, a “back” and “home” signals and that’s about it. Enough to start playing. The entire codebase for the app is available on my gitHub page: https://github.com/georgeschiopu/kodialexa

Step III: The Alexa Skill

Time now to dive in the Amazon Developer Portal and put the “skill” itself together. It’s not something that’s rocket-science, it’s more a matter of reading a bit of documentation (and they really do have documentation!) and do some trial and error. This is pretty much where you’re defining your Alexa skill interaction. You have your “intents” and your “utterances”. These are kind of how your voice commands are mapped to the application, what functions should be triggered and what parameters should be sent to your (next step) Lambda function.

{
    "intents": [
    {
        "intent": "GoRight"
    },
    {
        "intent": "GoLeft"
    },
    {
        "intent": "GoHome"
    },
    {
        "intent": "GoUp"
    },
    {
        "intent": "GoDown"
    }
]
}
GoRight go to the right
GoLeft go to the left
GoUp go up
GoDown go down
GoHome go home
SelectItem select item
SelectItem proceed
SelectItem engage
GoBack go back
GoBack level up

Step IV: The Lambda Function

The Amazon Lambda is a cloud platform that enables you to run your own functions/apps without the need to run a a dedicated server available online. You’ve got a choice of a few programming/scripting languages (C#, Python, NodeJS), I’ve chosen to go with NodeJS, closer to my day-to-day operations 🙂 I won’t paste the entire function written, it’s a mess to be honest, hey, I’m just getting started with this, ok? 🙂

Step V: The Result

Towards the evening, the pieces were ready to be glued into places and to tweak some bits and bobs. After a bit of trial and error, finally got it working. Planning to extend this to be a rich voice interface for my KODI media centre. For the moment it’s pretty basic, but pretty amazing, when you think of the possibilities.  

Amazon Alexa skills

Having the Amazon Echo Dot for a while now, I thought it’s about time to see how the “skills development” for Alexa works.

So far that was really simple, but in all fairness, it is a simple skill to develop. I named the skill “your favourite dog”, so you can invoke it with a simple “Alexa, talk to your favourite dog”, where “talk to” is the invocation “key phrase”.

I set so far just a few replies from Alexa:

  • Come here boy! Digger, you labradorable!
  • You need to eat! All your food!
  • You o.k. boy?
  • Who is a good boy?

This was pretty simple to do, all you need to do is to open a developer account on the Amazon Developer Portal, have an account with the AWS Lambda service and have some basic NodeJS skills.

And here it is! 🙂

Pitiful, isn’t it? 😀

Btw, only took me about one hour yesterday evening to set everything up. So far it’s only in “development mode” so it’s not available to enable the skill on the amazon skills marketplace.

Magento 2 Fundamentals

Yey! Finally managed to complete the “Fundamentals of M2 Development”  training course, and since it’s not yet a certification, it’s a nice to have on your cv. It consists of 6 units (modules), and after each one there’s a mini-test. So yeah, good to have, as I said.

Old school

Wow, my last post on this blog was more than 1 year ago!

Anyway, this post is about this year’s Christmas present that I got. Everyone who knows me know that I’m a kind of a “music freak”. Obviously, my wife knows this too 🙂
And she got me a turntable this year. She noticed the way I was looking at one of those some time ago in a store and she got me on. And of course, an album to go with it, Red Hot Chili Peppers’ Californication. This is one of the few albums that when I start playing, I don’t skip any songs. This one and Nirvana‘s Nevermind (which I bought the next day) 🙂

   

 

 

 

 

There’s nothing comparing to the sound of a vinyl record playing. The sound is way “full” than on the CDs or any streaming services, love it! 🙂

Another thing that I noticed, and it really is one of those “proud daddy” moments, my son Mihnea who’s 7 years old (according to him “almost 8!”) seems to really enjoy listening to Nirvana’s Nevermind! My eyes are full of tears, damn those onion cutting ninjas around me!!! 🙂

Thanks Wifey!

Magento Certified. Plus!

Recently (Thursday, 5/Nov/2015 to be more precise), had my Magento Developer Plus certification exam. After having my “normal” Magento developer certification in 2012, this one was long overdue, really. According to Magento, “you can now list yourself among an elite group of Magento professionals who have demonstrated their superior skills by passing the exam. Whether you are looking for a new job opportunity, contract work, or advancement in your current position, your new Magento Certified status gives you a valuable, verifiable advantage. The Magento Certified Developer Plus is skillful in the use of Magento Enterprise Edition and has delved into details of the structure of Magento that many have not often explored, but which can give someone an advantage when implementing a site using Magento.”.

Sweet talk, huh? 🙂

Oh, the link to my Magento profile page is here. It’s even got my picture and stuff! 🙂

Magento template path hints in adminhtml

I know this is all over the net, but I’ll post it here for my own reference.
So this is how you enable the template hints in the admin: connect to your database, an execute the following query:

INSERT INTO core_config_data (scope, scope_id, path, value)
VALUES ('default', 0, 'dev/debug/template_hints', 1),
('default', 0, 'dev/debug/template_hints_blocks', 1);

To disable them after you’re done, just set the new paths (dev/debug/template_hints and dev/debug/template_hints_blocks) to 0.

Simples!

Nginx / php-fpm timeout

So, I’m working on a Magento upgrade on a LEMP stack server, and in spite of changing 

proxy_read_timeout

to 1 hour (3600s), was still giving me the ugly “502 Bad Gateway” message.

Foud that there is a setting in PHP-FPM that should to hand-in-hand with the one in nginx, 

request_terminate_timeout

to be more specific. Increased that to 3600s in 

/etc/php-fpm.d/www.conf

, restarted the fpm service and voila! Works like a charm!

The default is set to 120s, btw.

Hope that helps someone.

//lateredit: There might be another setting

fastcgi_read_timeout

in your nginx conf file, that one needs to be set to the same value as the previous ones.