Last few weeks me and my team had to install around 10 third party Magento extensions. We have our own local setup and development workflow, but one of the key elements is MODMAN. All extensions (ours and the third party extensions) are linked in Magento by modman. With our current setup and the situation with the number of the new third party extensions we were forced to create modman files for all new extensions. We had to create manually the definitions in the modman files in order to define how the extensions files should be linked in Magento. There was no room for mistakes, but during the process we started experiencing problems, because of the human factor. From time to time we were missing to write modman definitions for some template, layout and css files.
I spotted the need that we need reliable and automated tool, which allows us to create modman files without missing any definitions. At the beginning I was thinking to write my own shell scrip, but as I didn’t want to reinvent the wheel I decided to use my professional network and to ask the Magento community (thanks to one of my first mentors Stefan Stefanov for always reminding me to search for existing concepts / tools / frameworks rather than reinventing the wheel). I asked for help in twitter. The first minute I published my tweet I got answers from Magento community members.
Continue reading “Magento: Generate modman files”
Today I worked on task that required the region filed to be removed from all Magento address forms. I found some Magento modules that were doing the trick, but I also wanted to delve a bit more deeper and to see if I can do this by configuration from Magento admin. Luckily in the most recent version of the platform ( Magento CE 1.9 ) this is possible.
By some simple actions in the Magento admin you will be able to exclude the region field from:
- Customer add / edit address form
- Customer register form
- Billing and Shipping address form on the checkout page
Below I am going to show 2 different solutions how to hide the region filed. The first is more suitable for Magento admins / store owners and the second is something that the developers can use in their data upgrade scripts.
For the both example below I assume that we have to remove the region if the country is Germany.
Continue reading “Magento: Remove the region from address form”
Not long ago, my team and I had to change our local Magento development environment to something new and experimental. We changed our local setup so right now we run Magento with docker. So far it’s still experimental and we change the Docker setup quite often. This means that we destroy and recreate the local environment quite often. One of the side effects is that we frequently destroy all sessions, and as a side effect, we get logged out from the Magento admin area a lot.
Furthermore, we are running Magento 188.8.131.52 and this version comes with a built-in protection to save the Magento admin credentials in the browser. Basically, by removing the protection we were able to save the login credentials and to login much faster. I decided to save some clicks and I created a simple Magento extension that automatically logs in developers when they try to reach the admin area. Basically, I wrapped in the extension code for the admin auto login that can be found on the Internet, but I polished the code up a bit and added some configuration settings.
You can download CeckosLab_AutoLogin by cloning it from GitHub or installing it with Modman.
Continue reading “Magento: Admin auto login extension”
Today, while I was browsing YouTube, I accidentally stumbled upon a video from April 2012. The video was from a hackathon organised by Osijek Software City and the main character was me. I had completely forgotten about the great time that I had back in 2012 and watching this video again made my day.
Also, I mustn’t forget to say “thanks” to my friends from Inchoo who invited me to attend this event. I remember that the trip from Bulgaria to Osijek was long and I felt very tired, but it was definitely worthy. I met new people at the hackathon and I had some great personal and technical conversations. As a matter of fact, I met my friend Vedran Subotic at this event who, two years after “opened the door” for my moving to München, Germany.
On the hackathon I had to work alone because most of the attendees had teams and the attendees who were alone were too far from my professional expertise. I wanted to do something with Magento but the potential team members were good at C#.
Continue reading “From the archives: Osijek Software City hackathon – April 2012”
A couple of months ago I had a really interesting and very importatnt task. I had to code an automated process that creates Unirgy_DropshipPo purchase orders (Unirgy_DropshipPo_Model_Po objects). Because the task had a very high business value and everything had to work flawlessly, I decided to invest more energy and time in order to write a good test coverage with phpunit. I also knew that I needed tests because there was a big chance my code would be modified in the following weeks because of the business dynamics. I decided to “step” on something that I already knew how to utilise – EcomDev_PHPUnit ( Thank you Ivan Chepurnyi ).
Initially, my idea was to use EcomDev_PHPUnit only as a unit-testing tool and to test functions in isolation, but at a later stage of the development I found out that it would be even better if I used EcomDev_PHPUnit to test different branches of my algorithm.
During the development phase I had 3 main technical challenges:
- Unknown / Unexpected behaviour of Unirgy Dropship
- Collecting fixtures data in order to simulate test cases close to production environment
- Querying the database in order to prove that entities have been modified or created (Purchase order, credit memos and etc.)
Continue reading “Magento: Tips and tricks how to test Unirgy Dropship module with EcomDev PHPUnit”
During the last few weeks I’ve been having a lot of fun with my current project. Recently I had to invent SQL queries in order to fetch data from the database. “At the end of the day” I had a nice looking-query but it was really slow. The query was taking around 1.2 sec to execute but it was really simple and had to be executed in a production environment every 30 minutes. By our standards, we couldn’t allow such a slow query on a Magento production shop. In addition, I will say that the query was executed on a table where we had many insert and update queries while the customer was interacting with the Magento frontend.
After a short investigation I found out that adding and index to a column that I was using in the where clause reduced execution time from 1.2 sec to 0.02 sec. The good news was that the table to which I wanted to add the index was part of our own module (not part of a core or community module) and I had the freedom to add this index without doing any “harm”.
Continue reading “Magento: Add column index from upgrade scrip”
This morning I was looking for some new and interesting articles and I found one titled Are You Giving Your Users Positive Feedback? In this article I’ve found one very simple and elegant solution of something that always bothered me while shopping online. As I’m impatient person I always have problems with clicking more than once on the add to cart button and few times I’ve purchased items in bigger quantity that I’ve intended. I’ve never seen a web shop, that offers this simple solution presented in the article I’ve read – adding message for items that are already in the shopping cart.
Continue reading “Magento: Check if product is already in cart”
In my last project, I had to deal with the following task: All registered customers and all guest customers who tick the “Create an account for later use” option on the checkout page to get free shipping in combination with the OneStepCheckout extension of Magento. This was the first time I had to manage a task of the kind, and in situations like this, I first decided to ask Google for help.
And I came across this page: Free shipping only for registered users where Srdjan Bajic had provided a solution. As I mentioned at the start, this should work with OneStepCheckout and now I am going to show you how I implemented it in OneStepCheckout.
Continue reading “Magento: Free shipping for registered customers in combination with OneStepCheckout”
In Magento If you have case when you need to check if some object is new ( just created ) in after save callback, in some function where you use $object->save() or somewhere else, you can use next method:
This function is available in all Magento CE releases >= 184.108.40.206
Continue reading “Magento: Check if object is new after save – isObjectNew”
Have you ever had problems with custom fonts embedding, while trying to generate PDF ducoments in Magento or using Zend Framework. May be I found solution for you, If you get next error message:
“This font cannot be embedded in the PDF document. If you would like to use it anyway, you must pass Zend_Pdf_Font::EMBED_SUPPRESS_EMBED_EXCEPTION in the $options parameter of the font constructor.”
As a result of my research I decided, that the problem comes from Zend Framework core and seems, that it doesn’t recognize correctly if your custom font can be embedded if has some embedding permissions.
What I mean, when say embedding permissions:
- Licensed for print and preview embedding
- Licensed for editable embedding
- Licensed for modification
Continue reading “PDF Font embedding problem in Magento / Zend Framework”