Blogging and how to develop for Magento

I’ve been working as a a Magento developer for just under 4 years now. Looking back I can think of 47 different sites I have worked on to varying degrees, from styling blog pages to full custom ERP integrations.

I don’t think I would be where I am now, with the knowledge that I have without sites like the Inchoo Blog (Always great explanations), Magento Stack Exchange (Answers with varying degrees of helpfulness) and others. I now feel that I have enough experience and understanding of Magento to create some useful tutorials and how-to guides and would love to give back to the community I learnt so much from. However, I really want to avoid the “copy my code, and you’re done” style tutorials.

When I was first starting out I found these guides could be useful… if you needed to do exactly what they were doing in the guide and nothing else, but as anyone who has ever dealt with Magento will know, it’s not always that simple. You will have business, client or process requirements to fill so all of a sudden that guide you are following isn’t quite as useful as you first thought. As you learn more and more you have the understanding to change these examples for your own needs, but when you’re staring out, or haven’t worked with that particular feature sometimes its not so obvious.

What I’m aiming to do here is to put code up, but also to actually explain what its doing and why we are doing it that way. I’m hoping this gives people the information and knowledge to be able to understand enough to do what it is they need to without being stuck looking for another guide.

I have a bunch of posts that I’m currently drafting covering a number of subjects including:

  • MSI (Multi-Source Inventory),
  • Certification,
  • Using and creating APIs,
  • Effective use of di.xml,
  • Various issues I come across on a day-to-day basis and solutions.

I currently work for an amazing Magento agency so get to work on some really interesting projects and I’m hoping that will give me more ideas as time goes on. As I was writing this post I was thinking that it would be good to aim for a post a week, having thought about it however, even this post which is just me talking about what I want to write about has taken me a long time just to think about and actually type out in a coherent way. Some of the drafts with code I’ve already spent more than an hour or 2 on and they are not even close to completion. I think I’m going to aim for 1 per month and if I can try for every other week as I get better, but we’ll see how things go. It would also be quite cool do to some videos I think as well but I hate the sound of my own voice so I think I’ll leave that on the back burner for now.

Thanks for taking the time to read. If you want to get in touch or you have any ideas for things you want me to post about then feel free to reach out on the social networks linked up top.

Brewdog for a non-beer drinker

Probably a year or two ago now I invested in Brewdog as a bond-holder. For those of you that don’t know what a bond is it is similar to a loan. I effectively “leant” £500 to Brewdog and get around 6.5% P/A ROI. Any of you that know me may think that is a strange thing for me to invest my hard earned pennies in as I really can’t stand beer. For someone with a large amount of liquid capital this would just be another investment opportunity, but for me, it was kind of a big deal.

So why? Well, today as a perfect example of why I invested in them. I had nothing to do, all my fiends were busy, so I went there for lunch/dinner on my own. Yes, I, know, a bit sad but if anyone wants to go with me I will be more than happy to do so. I have been to the Brighton bar a lot. The staff immediately recognised me, greeted me with a smile and knew what I liked to drink. In this day and age of diminishing customer service it is a fresh breath. I really appreciate this and I’m proud to have put what I have behind them, however insignificant of a difference I may have made. In particular the bars in Brighton, Camden and Soho, thank you for making me feel welcome. I don’t feel I’m alone in getting a bit peeved with companies where the staff treat you as an inconvenience rather than a source of revenue, you guys certainly stands our from the crowd!

On one occasion James Watt (Capitan of Brewdog) was behind the bar. Bit if a shocker, but incredibly pleased to see staff from high-up on the front lines instead of stuck behind a desk.

One thing is clear across all staff from all branches of this company. They are passionate, able to speak with fluency and recommend drinks. Why would this matter to me? After all, I only drink cider! On the few occasions they did not have a cider on tap/bottle they asked what I did/didn’t like and were able to recommend a drink for me. I didn’t like it as much as what I would normally be drinking but they recommended me a drink I could finish and actually kinda enjoy.

Ps: Brewdog… if you’re reading this, I know you have your hands full with Lone Wolf, US brewing facilities and more bars, but I’d bloody love it if you could crank out your own cider at  some point.

Long running tasks over SSH

Recently I found myself having to execute some long running tasks (running find with -exec on a directory with millions of files) on a linux server over SSH. This can cause a bit of an issue if you want to go away and do something else or if you have an unreliable internet connection. This is because as soon as you SSH session disconnects the current process ends. This happens wether you close the connection yourself or the frustrating packet_write_wait: Connection to some.ip port 22: Broken pipe error. There are a couple of solutions to this:

Screen

Screen is a program that allows you to have multiple “windows” open without having to create separate SSH sessions for each process. I had always meant to learn how to use this program but there were a lot of options and I always put it off, however like many programs I found there are only a few options you need to learn to get work done.

To get started first SSH into the server we need to run the task on and run screen.

In my case I got this: -bash: screen: command not found

Not a problem, just install with sudo yum install screen and select yes when asked to confirm.

installing screen

I’m on CentOS so used yum, for debian based distros use apt-get

Now it’s installed lets try again. You may be presented with a welcome screen but you can just tap space or enter to continue. This will take to to a new empty shell. From here you can run tasks a normal. Lets say you are trying to find all .txt files in your home directory you might use something like find ~/ -name *.txt and depending on how many files it has to search through this may take a while. Not to worry. Press Ctrl+a then d and your screen will be “detached” and you will be returned to the main shell:

[code]
[detached from7938.pts-2.newbury]
[[email protected] ~]$[/code]
From here you can close your SSH connection and come back in your own time. To “re-attach” simply screen -r yourSessionId in my case this would be screen -r from7938.pts-2.newbury If you can’t remember the session ID you can also run screen -ls which will show you something like:

[code]
[[email protected] ~]$ screen -ls
There is a screen on:
7938.pts-2.newbury (Detached)
1 Socket in /var/run/screen/S-craig.

[[email protected] ~]$
[/code]

Next run screen -r 7938.pts-2.newbury and you will be re-attached back to the session.

Theres also a handy feature to name sessions. From within the session type Ctrl+a

then :sessionname mysessionname

 

Nohup

This is another program that allows you to run programs without the risk of them being killed on disconnect. In-fact they way I have been using this I haven’t needed to come back, leaving it run on it’s won was fine so nohup some-command & did the job fine. The & tells the OS to put the job into the background. If you need to see if its still running then jobs -l will do the trick for you. You will get output similar to this:

[code]
jobs -l
[1]+ 13100 Running nohup find / &
[/code]

Where “13100” is the PID and “nohup find / &” is the command you ran. You can still kill the process, say for example services start having latency/responsiveness issues by using kill 13100  (SIGTERM/Graceful process end) or kill -9 13100 (SIGKILL/Forcing the process to end).

 

Starting a blog

For many years I have been meaning to start a blog. Every time I have a thouht, I think “I should write this down”. I have so much going on In my head that I want to get out, and would live to get peoples thought on that I thought it was about time that I actually did something about it.

I’m a massive geek so you can probably expect to see posts about all the things I am learning including HTML, PHP, CSS, JavaScript, Magento, Swift/iOS, electronics annd much more.

Stay tuned. Hopefully you find something interesting here. Let me know what you think.