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.

Mage Titans

If you are a Magento developer, you pretty much know what this post is about. If you were last Saturday (1.Nov.2014) in the Manchester area, you definitely know what this post is going to be about. If you don’t… well.. sorry for you! 🙂

This post is not going to be another review of the event, couldn’t do that even if I wanted to, I think I’m too close (personally) to do that.

Last Saturday, in Manchester, at “The Comedy Store” the first edition of the “Mage Titans” conference took place. I’m proud of being part of this from the beginning, when it was just and idea spinning around the Space 48 offices, ever since we were trying to find a name, to think who to invite as speakers, etc. And, thanks to our amazing team, in partnership with Manchester Digital developed the idea into something that no one was expecting.

You see, the thing with Magento, being the “beast” that it is (especially being an eBay company now), most big conferences around the world (Meet Magento, Magento Live, etc) have a tendency to be a bit more commercial, more business-oriented than a “nerdy developer” would like. No disrespect for anyone, I’m one of those as well. But Mage Titans was exactly the opposite, it was (like Jon, the Space 48 MD said it really well) “for developers, by developers”.

The thing that blew me away (well, one of them anyway) was having the opportunity to be in the same room with guys like Vinai Kopp, Ben Marks, Alistair Stead (to name a few) and to be able to speak with them, exchanging ideas, getting advice, talking about best practices, hearing some really good tips. And after all that, to realise that, at the end of the day, they’re developers, like everyone in the room, that day. There no CEOs, no MDs, just Developers. Even better, Magento Developers.

Me & Ben Marks

I mean, hearing Vinai Kopp with his talk entitled “The Beautiful Magento Module” was a great kickoff for the day. And the day finished with Magento’s own Ben Marks, the “dude” who’s training videos I was watching almost three years ago getting ready for my Magento Certification exam. Not to mention Alistair Stead‘s tips and tricks, dos and don’ts to scale and have your Magento solution highly-available, having your Magento getting closer to the speed of light with HHVM by Daniel Sloof, or loads of information on caching and debugging with our own Space 48 Technical Director, Tony Brown.

By far, the most important part of the day (and I know for sure most of the devs in there agree) was the Panel Discussion, with Ben Marks, Vinai Kopp and Alistair Stead, moderated by Tony Brown, where anyone had the opportunity to ask questions and have not one, but 3 answers. It was both informal and fun, could have stayed there another hour or more 🙂

The Panel!

I won’t post in here links to the speaker’s slides, you can find those online if you do a quick search on Google or if you follow the speakers on Twitter.

I will, however, post a URL with the images I took that day: https://plus.google.com/photos/+GeorgeSchiopu29/albums/6076877709958501345

By the looks of it, I see absolutely no reason why there should’t be a “Mage Titans 2015”, right? Looking forward to it!

 

Cheers,
George