Wojtek Naruniec

Meet Magento 2014 Poland remarks

It’s been almost two months since I got back from the Meet Magento Poland 2014 conference. These last two months were really busy for me and a lot of things are still going on. I haven’t got a chance to write about the event yet. I decided to not write a full story, but I’m going to wrap up a random list of notes and thoughts I have gathered after the conference.

My remarks

  • interesting case study of a multi-store and multi-language Magento integration was presented by LPP and Accenture
  • it was hard to switch between Business and Technology tracks and I lost more than half of Kuba Zwoliński presentation about iBeacon. I hope to see videos from the conference sometime soon!
  • there was a nice introduction to Magento 2 caching by Marko Martinović. I was surprised that the Magento 2 Community Edition includes Full Page Cache support
  • good points on contributing to open source Magento extensions and projects in general by Tsvetan Stoychev from Jarlssen. I still need to review extensions published on Jarlssen github
  • I couldn’t watch Damian Luszczymuk’s presentation about Docker as I chose the Flexible Billing talk by our CEO, Matt MacDougall. However I was really lucky and Damian showed me the presentation in brief later that day. I promise to dig into Docker soon.
  • there was an interesting case study on Magento-SAP integration made for Mennica Polska by Robert Żochowski from Bold Agency. I’m excited to buy some gold from a store based on Magento.
  • I got some interesting ideas about introducing developers to Magento development and noted a bunch of training materials from Ben Marks presentation
  • Daniel Sloof made a good overview on HHVM and I’m curious to see Magento 2 running on that engine
  • our booth with space figures and NASA suits was very successful, bringing a lot of people to our place!
  • I missed the presentation about Magento indexers by Maciej Ostrowski and I hope to see the video soon
  • I saw a cool demo of cobby.io, tool which allows me to manage product data in Excel. It sounds like a crazy idea but looks really interesting and works nice
  • community dinner at Podwale 25 restaurant was delicious. I hope to visit that cool place next time I’m in Warsaw
  • enjoyed Thomas Goletz’s story about Gobi desert race and about Chinese Magento branch
  • conference iPhone application was really cool, however iBeacon stuff didn’t work on my iPhone. It’s time to move to the new one

These are just random thoughts I got after the conference. I really liked the event and I hope to go to Meet Magento 2015 later this year :-)

Photo made by Viacheslav Kravchuk, Atwix. Thanks!

How to prepare Magento 2 beta package for offline use

Magento 2 comes with a composer installer and all external dependencies including sample data are being installed using composer. However, I needed to have a simple way to install Magento 2 along with sample data in an offline environment, without using composer. I had a few reasons to do this – I wanted to have a fast way to install Magento 2 multiple times and I wanted to test command line installing for MageTesting.com purposes.

Main goals are:

  • avoid downloading more than 1 GB of data each time
  • let it work in offline mode
  • operate with smaller packages
  • simplify steps needed to install Magento 2

Cloning GIT repository and downloading dependencies resulted in downloading more than 1GB of data:

  • Magento 2 code cloned with packages downloaded using composer: 471.3 MB (194 MB after gzipping)
  • sample data media: 590.9 MB (zipped)
  • sample data code: 0.2 MB (zipped)

I decided to prepare a Magento 2 package which contains only code needed to run application and to prepare sample data package which could be installed just by copy pasting that into Magento 2. Recently I was playing with a sample data compression script provided by Vinai Kopp, and I made a fork which can compress Magento 2 sample data.

At the end I have the following packages:

  • Magento 2 code (26 MB, gzipped)
  • compressed sample data media (92MB, zipped)
  • sample data code: 0.2 MB (zipped)

I know there is a composer cache. I know I could use Vagrant/Docker or other virtualization, but still I wanted to avoid overcomplicating the process. If you see that use case useful, please find all needed steps described below.

Just keep in mind it is written for 0.42.0-beta1 release of Magento 2 and it is not a recommended way to install Magento 2.

Prepare Magento 2 package

1. Clone GIT repository

git clone git@github.com:magento/magento2.git

2. Install composer dependencies

composer.phar update

3. Remove huge directories not needed to run application

rm -rf dev/tests
rm -rf .git
rm -rf vendor/magento/zendframework1/documentation
rm -rf vendor/magento/zendframework1/tests
rm -rf vendor/magento/zendframework1/demos

4. Prepare package

tar czf magento2-0.42.0-beta1.tar.gz -C magento2/ .

Prepare Magento 2 sample data package

1. Downlod demo data

curl -O http://packages.magento.com/_packages/magento_sample-data-0.42.0-beta1.zip
curl -O http://packages.magento.com/_packages/magento_sample-data-media-0.42.0-beta1.zip

2. Compress demo data

compress-sample-data-magento2.sh magento_sample-data-media-0.42.0-beta1.zip

Install Magento 2 using created package

1. Prepare directory and unpack package:

mkdir magento2
tar xzf magento2-0.42.0-beta1.tar.gz -C magento2/

2. Set required permissions

cd magento2
chmod -R 777 var/
chmod -R 777 pub/media/
chmod -R 777 pub/static
chmod -R 777 app/etc/

3. Run Setup

php -f setup/index.php install 
    --base_url=http://local.magento2new.com/ 
    --backend_frontname=admin 
    --db_host=127.0.0.1 
    --db_name=mage2 
    --db_user=mage2 
    --db_pass=mage2 
    --admin_firstname=John 
    --admin_lastname=Doe 
    --admin_email=john@example.com 
    --admin_username=admin 
    --admin_password=admin 
    --language=en_US 
    --currency=USD 
    --timezone=Europe/Warsaw

Install sample data using package

1. Unpack media sample data

unzip -q -d pub/media/ compressed-magento_sample-data-media-0.42.0-beta1.zip

2. Unpack sample data code

mkdir dev/tools/Magento/Tools/SampleData
unzip -q -d dev/tools/Magento/Tools/SampleData magento_sample-data-0.42.0-beta1.zip

3. Install sample data

php -f dev/tools/Magento/Tools/SampleData/install.php -- --admin_username=admin

4. Make sure newly added files are writable:

chmod -R 777 pub/media/
chmod -R 777 pub/static

This one is a little dirty, but as far as I know composer doesn’t support installing local packages.

Let me know if you find this article useful and if you have any thoughts around that.

How to easily dump Magento database with n98-magerun

It looks I felt in love with a n98-magerun tool. I already talked about my favourite n98-magerun commands and about a command which allows to generate fake customer data. Today I’m going to continue n98-magerun post series and focus on a command which allows to make database dump very easily. n98-magerun.phar db:dump in addition to commands mentioned in previous blog posts is another one must have.

The command allows to dump a database very easily. Similar to a n98magerun mysql-client command, it doesn’t require me to enter a password and look for any connection details. It automatically generates a dump file name based on a current date and time, allows to use built-in filters to exclude big utility tables and finally creates an archive after completing the dump.

Sample calls may look as follows:

n98-magerun.phar db:dump
n98-magerun.phar db:dump --strip "@stripped @ee_changelog @idx"
n98-magerun.phar db:dump --strip "@stripped @ee_changelog @idx" --compression=gz

First call produced a 5.1 GB file containing all database tables. Second stripped a bunch of database tables such as changelog tables, index tables, reports or logs tables and it resulted in reducing the database dump to 3.1 GB. Third one called with a compression option reduced size to about 251 MB. Third gain is expected and it could be also achieved with one additional gz command call, but it’s really convenient to do a gzipped dump in one command call.

Stripping not needed database tables can save gigabytes of transfer when working with a big database. However, it won’t fit all use cases, for example in which you need to prepare a dump to debug index problems where you need to get an exact state of a Magento application database.

Get a free Meet Magento PL 2014 ticket!

It’s only 9 days left to a Meet Magento PL 2014 conference which will take place on November 24th and 25th in Warsaw. There is a lot of interesting presentations announced for this event in the Meet Magento PL agenda. Rocket Web Inc. will also be on a stage – Matt MacDougall will talk about Flexible Billing models.

Are you going to attend to a conference and you haven’t got your ticket yet? Or maybe you are going to bring a friend? I have one free ticket to give away! If you want to get one, just write a comment under the post and say why do you want to go to the conference.

Contest begins on November 15th and ends on November 19th. I will announce the person who gets the pass on November 20th.

See you in Warsaw, make sure to stop at our booth :-)

Confession: I haven’t made any purchase using mobile yet

I have worked for a Magento partner company for a few years. I have worked on projects utilizing a responsive web design concept and I have made a lot of test purchases in these projects using mobile devices. Recently I realized one thing – I have never bought anything real using a mobile device! However, I was using the App Store on my iPhone, but it doesn’t include checkout so it doesn’t count.

I make a few purchases in online stores each month. It’s usually electronics and gadgets stuff, books and toys for the kids. I used to buy groceries online and for a few months I have been buying clothes and shoes there.

When I realized that I haven’t bought anything using the technology I am working on, I was ashamed a bit. My first thought was that it’s not a great idea to share this. However, it’s time to change that. I’m going to buy only using my mobile phone for at least the next 30 days!

Fix Apache broken after OS X Yosemite update

I could call it OS X tradition, Apple again broke the Apache 2 installation with latest OS X Yosemite upgrade. Let’s see how you can fix that and bring your local Apache2, PHP5 and MySQL development environment back.

I did very naive thing and just started the Apache 2 using sudo apachectl start . It worked, I got “It works!” page but nothing more. Then I reviewed Rob Allen’s article about setting up PHP & MySQL on Yosemite. He described steps on setting that on clean install but I needed to go through different steps as I had everything already installed. However, the article was helpful as it covered a few parts of the process.

If you have Apache 2 already installed, these steps can help you to go through to make it working again:

Update Apache 2 configuration

1. Uncomment Virtual Hosts line in Apache2 config (/etc/apache2/httpd.conf ) if you use that file to configure all hosts:

Include /private/etc/apache2/extra/httpd-vhosts.conf

2. Change Access Control block in httpd.conf as it has changed in new Apache 2.4:

AllowOverride All
Require all granted

3. Uncomment following lines to enable mod_rewrite and PHP5:

LoadModule rewrite_module libexec/apache2/mod_rewrite.so
LoadModule php5_module libexec/apache2/libphp5.so

4. Restart apache:

sudo apachectl restart

After doing these steps my local sites started working again along with PHP5. However, Yosemite upgrade also removed custom extensions and at least Xdebug and Mcrypt were missing.

Reinstall Homebrew

I wanted to follow Rob’s guide regarding Mcrypt in which he used a Homebrew. Unfortunately the Homebrew didn’t worked for me as I didn’t upgrade that before upgrading OS X to Yosemite. I reinstalled the Homebrew then:

1. Remove old Homebrew

sudo rm -rf /usr/local/Cellar /usr/local/.git && brew cleanup

2. Install latest one

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

3.Run brew doctor

brew doctor

It came with a few recommendations. I fixed some of them, then I did the last one which was upgrading Xcode to 6.1. Actually Rob mentioned that in the article but I missed that part. It’s the following package:

https://developer.apple.com/downloads/download.action?path=Developer_Tools/xcode_6.1/xcode_6.1.dmg

Remember to run Xcode ater upgrading, it can save a lot of time later. I didn’t run that and I couldn’t get Mcrypt PHP extension installation working. After installing and running Xcode you also need to install Xcode command line tools. Run following in console to do so:

xcode-select --install

When Brew and Xcode are on their place, proceed to a Mcrypt installation.

Install Mcrypt

That part comes from Rob Allen’s post mentioned earlier.

1. Install Mcrypt using brew:

brew install mcrypt

2. Prepare for PHP extension installation

Run following commands:

brew tap homebrew/dupes
brew tap homebrew/versions
brew tap homebrew/php

I haven’t been able to run successfully some of these commands on my local. I needed to follow recommendations mentioned in commands output eg. to clean some symlinks, install some other packages using brew install, etc.

When  these repositories are added, edit one broken file and apply patch:

/usr/local/Library/Taps/homebrew/homebrew-php/Abstract/abstract-php-extension.rb

3. Install PHP extension:

brew install php55-mcrypt --without-homebrew-php

4. Enable PHP extension:

sudo mkdir -p /Library/Server/Web/Config/php
sudo ln -s /usr/local/etc/php/5.5/conf.d/ext-mcrypt.ini /Library/Server/Web/Config/php/ext-mcrypt.ini

Then restart apache again and mcrypt should work properly.

I’m really happy I made my development environment working after Yosemite upgrade. I also realized what should be the next step – I should get rid of MacPorts leftovers and make sure everything is installed using one package manager.

I hope these steps and Rob’s article can help you in fixing OS X web development environment.

Bring a lot of customers to Magento store… using n98-magerun

Recently I talked about my favourite n98-magerun commands, this time I’ll continue that topic. Let’s see how to easily add a lot of customers to a Magento store. Of course it’s about adding fake data for testing purposes, unfortunately n98-magerun doesn’t help in bringing real ones :-)

Command customer:create:dummy allows you to create dummy customer accounts for testing purposes. It supports a few different locales and allows to generate any amount of accounts.

$ n98-magerun.phar customer:create:dummy 1000 pl_PL
[…]
Please select a website: 1

It took about 13 minutes to create 1000 customers, so it is able to fill a database with thousands of customers in a few hours. Sample output looks as follows:

Customer wieczorek.julia.152196@example.org with password QAELhMP! successfully created
Customer fabian.291162@example.net with password 8grCBZ9$ successfully created
Customer emil.108200@example.com with password ARWRJALy successfully created
[…]

Internally it uses https://github.com/fzaninotto/Faker. That library allows it to generate other assets like texts (either lorem ipsum or more real ones), addresses, phone numbers, companies, date and times, internet accounts, payment data and a few others.

I would love to see the ability to generate products using Faker and have a few more dummy methods incorporated into n98-magerun. The ability to generate products, customer addresses, maybe sales data would be great. However, the ability to generate fake customer accounts helps a lot and it’s a great start.

Work from anywhere

I have worked remotely for a few years. Actually I have worked remotely almost since the beginning of my career. There was a time when I was heading to the office almost everyday, but it was just “almost” and I wasn’t able to hang on there for more than 5 or 6 hours.

I love the mobility and ability to change the place I’m working from. Usually I work at my home office or on the terrace. Catching up with other team members is also important so this month I worked for a few days in our Bucharest office, and next month I’m going to start working in a co-working space once or twice a month. Sometimes changing to a completely different environment helps me to maximize productivity and keeps me happy.

This summer I got a chance to stay in a cottage house in Uniszowa for a week and work from there. It’s a place located in the Western Carpathians, so calm that it’s hard to see any house in a neighborhood there. The only thing I needed to figure out was the internet access. Fortunately it was really easy as the cottage was in a 4G LTE network coverage so connection was even better than at home. I was only missing a comfortable chair there but a sunbed did the job for these few days. Photo above shows a lovely sight I had from my work space.

I’m looking forwad to go to Uniszowa again this year. However, I need to wait til next summer to try a few crazy ideas about working from other calm and quiet places – work from forest or meadow :-)

What other places do you recommend for remote work?