Changes. Big Changes!

I’ll try to keep this short.

So, a bit over 6 years ago I was knocking on a new door, having an interview for a “web developer” position. Got the job (phew!) and so an amazing journey started. I do remember we were a handful of people in a tiny office in Birchwood, Warrington.

The reason for this “sudden nostalgia” is that las Friday was going through my drawers in the office and found this gem:

Optimise Internet

Although most people know us as “Space 48“, the company started as “Optimise Internet”.

Now, the reason why I was going through my drawers in the first place is that we’re moving offices. We decided that Birchwood isn’t enough for us anymore and so we’re moving to Manchester. And I mean the City Centre, you can’t go any more “central” than that.

Of course, we’re not just a “handful” of people anymore (more than 30 now if I remember correctly), and I’m not just a “web developer” anymore (“Technical lead” currently).

This is us getting our stuff together getting ready for the “big move” on Friday:

And here’s a few images from what awaits starting Monday (9th/10) morning, shots taken by my colleague Adam Moss (@adampaulmoss on instagram): https://www.instagram.com/p/BZ67YHHF8GR/?r=wa1

We also have a new “hashtag” we’re using on Twitter and other social media sites to let everyone know “we’re coming”: #InvadingMcr so keep your eyes on that one for (a lot of) new images in the next few days.

Comments

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).

Here it is:

I’m trying to add new products to a Magento 2.1.7 and noticed some strange behaviours when it comest to global attributes (special_price for this example), found a workaround (kind of…) and was looking for a confirmation from the community if what I’m seeing in there is correct.

So, scenario: Magento 2.1.7 installation, only 1 store.
The endpoint used is rest/V1/products/, but using it like that, although it assigns the product to the one store I have in the installation, it also creates a row in the >catalog_product_entity_decimal table having store_id as 1, when a global attribute should have only 0 – is that correct?

Now, that attribute ends up in being a rogue row in there because no matter what I’m trying in the admin to do with it, being a global attribute, the admin’s not touching that at all. The problem on the frontend after that is that the product in question will always show the special_price, because it finds an attribute with the current store_id, doesn’t matter if it’s global or not, it just shows it (now this is an assumption, haven’t checked that, must admit, but it kinda makes sense).

If I am changing the endpoint to rest/all/V1/products/ it does not create the store_id=1 attribute in that table, but the product is not assigned to the store front either, and although now the special_price is not an issue anymore, I have to go in the admin for all products created like that and assign them to the only default website in order to be visible on the front-end.

Doing a bit more ‘light reading’ through http://devdocs.magento.com/swagger/index_20.html
I found that I can follow up the initial API call when I create the product with the /all/ endpoint that eliminates the special_price problem with another call for rest/all/V1/products/webites with the following JSON payload:

{
    "productWebsiteLink": {
    "sku": "newly-created-product-sku",
    "websiteId": 1
    }
}

It assignes the product to the only available website, shows in the front-end and all my problems are solved.

Now, the ‘million dollars question’: is this normal? Is that how it should be done? Create the product unassigned to a website and follow that up with another API call to assign it? If so, is there somewhere in the documentation that tells you the exact steps to follow?

The closest thing I could find about this problem (although it states it’s about getting products) is this: https://github.com/magento/magento2/issues/8121 and I got there following https://magento.stackexchange.com/questions/181906/magento2-save-product-data-for-global-scope-using-rest-api

Any opinions/links/advice will be greatly appreciated.

Thanks

I’m not sure if the lack of replies are due to this being a stupid question, but I kinda figured it out in the meantime, that pretty much how you should use it: create the product and after, assign it to a website with a subsequent API call.

Digging a bit deeper, I found another problem though: let’s say you want t create a few simple products that are going to be the part of a configureable product – make sure you reflect that “option” in the product, it’s not enough to change just the SKU in the json payload when you create the product.

The reason for that is that Magento created the value for the url_key attribute at the of creating the product, without checking if the same value already exists in the catalog_product_entity_varchar table. You can create a new product with the same title, you can even update info abut an already existing one, but when you’ll try to assign it to a website, it will throw an error stating that URL key for specified store already exists .

Good enough reason to post on my blog! Yey!

Comments

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:

Dear George,

Hope you are well today.

I am representing an organisation that has tasked me to get in contact with you due to your JAVA knowledge, industry background and work ethic. I appreciate that you might not be looking for a change right now. However, due to the rare and high attraction of this opportunity I would hope this message initiates enough interest to start a conversation about your current work situation and your motivations are for the future…

The company in question is one of the most disguised within the U.K who are fortunate enough to be in partnership with some of the largest and reputable companies in the U.K. They are a consulting company by nature but I don’t want to scare you with the words “consulting company”. The reason being is that they are very different to other organisations as they only deal with long existing partnerships with some of the most highly reputable companies in the U.K and in the world. It is there business plan to hire professionals who can add value to this vision and to have good programming knowledge and an interest in furthering their career through potential team leading and/or even management roles. All of this is possible with the way they are progressing their organisation.

Their belief is that the key benefits of working in this way is that you will get the cultural benefits of an “in-house” role, with the attractive travel options and close team orientation but you also get the consultative benefits. Such as exposure to the latest technologies, career/skill development which is more structured and also the personal benefits like salary, health plans/pensions and company car. It is there vision to bring the best of both worlds together.

I hope you like the sound of this company and I will be more than happy to discuss this in more detail in a telephone call.

I look forward to hearing from you.

I made it a rule of mine not to reply to emails like that, but this time I couldn’t help it, so I sent this:

Dear Chris,

First of all, my JAVA knowledge tends to be close to 0 (zero), nowhere in my CV (or my LinkedIn profile, for that matter) is there such a statement.

Another thing is that I have no idea what a “disguised” company is – are they in hiding by any chance? Or you mean “distinguished”, which has an entirely different meaning?

Also, I can only assume you wanted to let me know at some point in your message about “their vision”, “there” denotes a location as far as I know.

And one last thing that puzzles me a bit, is that the “subject” of your inMail says “0% Travel” and yet, in the last paragraph you mention something about “attractive travel options”.

Joke aside now, mate, make sure you get your messages straight before sending them, you’re really not inspiring any kind of confidence, really…

Kind Regards,
George (not a JAVA developer)

Just thought it’ll be good to leave this here…

Comments

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.  

Comments

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.

Comments

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.

Comments

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!

Comments

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! 🙂

Comments

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!

Comments

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.

Comments