Programming

Programming? Aren’t 80% of the articles programming related? Well, yes. However, there are some that are really related to programming style, best practices, etc or ones that we couldn’t place anywhere else.


Version control systems in UI design

Version control systems in UI design

Our design team switched to working in Sketch a while ago but it wasn’t until version 43 we really started seeing some opportunities to change our workflows more significantly. It was also an opportunity for more designers to work on the same project as well as collaborate with developers more easily. If you’re looking for professional Magento web design services, feel free to check out our Magento Web Design Service for more information.

Read more

Add Pagination to Custom Collection in Magento

Add Pagination to Custom Collection in Magento

If you are starting with Magento, just like I am, you might run into the issue of adding pagination to your table, list of products or anything else you want to list on frontend. Magento allows you to create your own pagination with adjustable built-in options. This tutorial will show you how to create pagination for a custom collection in Magento.

Read more

Thou Shalt Not Do Inserts in a Foreach … Unless You Know The Trick

Thou Shalt Not Do Inserts in a Foreach … Unless You Know The Trick

TL;DR;

Don’t do it. Just, simply, never write a database query inside a loop. Ever. Put in a little bit of effort and write code that will insert or read all data in one big batch, or at least group big chunks of data in the smallest possible number of queries. That’s it. Move on. These aren’t the droids you’re looking for.

Read more

Inchoo’s compatibility extension for Magento 1 and PHP 7

Inchoo’s compatibility extension for Magento 1 and PHP 7

As promised,  we prepared something that will spice up your holidays better than Christmas decorations and mulled wine. In this article you can find our open-source compatibility extension for Magento and PHP 7 (yes, you read that right!) as well as some of the experiences and performance tests.

Read more

Adding static blocks to specific CMS pages with Magento layouts

Adding static blocks to specific CMS pages with Magento layouts

While working on a project, I had to add a unique static block between header and main content of the CMS page on each CMS page. Element had to be fully customizable via Magento admin panel and it had to be easy to create on new CMS pages, easily modifiable and removable. Since that element needed to be placed outside of the main content, it couldn’t have been added using CMS in Magento admin. It had to be added using Magento layouts. Here’s how I achieved that.

Read more

Large number of input variables in Magento

Large number of input variables in Magento

UPDATE: The issue described in the following text has been taken care of in Magento EE 1.14 / CE 1.9

Recently, a pretty strange issue occurred on one of our projects. Our client reported that when trying to assign products to a category, only a thousand of products got saved while the other ones were ignored. To deal with this issue, I decided to jump to the category save action and check for any problems with the code that may cause this behaviour.

Read more

Creating EAV based model(s) in Magento

Creating EAV based model(s) in Magento

Magento EAV (Entity Attribute Value) data model is used to get flexibility for your data, but it brings more complexity than relation table model. If you need data model that will have flexible attributes which can be dynamically added, for example from Magento admin panel, then EAV is the best solution for you. If using EAV, you don’t need to change table structure for every new attribute like you do on flat tables (creating new colums).

Read more

Programmatically create a configurable Magento product

Programmatically create a configurable Magento product

I already wrote about creating a simple product programmatically in Magento. For configurable product, however, things get a little bit complicated.

As you already know, a configurable product is merely a product with simple products that differ in some option (attribute) assigned to itself.

We can use this conclusion to extend our code for creation of simple products to work with configurable.

Read more

Sort products by sold quantity in Magento

Sort products by sold quantity in Magento

Magento by default comes with a few basic product sorting options such as sorting by product position, name or price. In this article you’ll learn how to sort products by how many times they have been sold.

Read more

Programmatically (manually) creating simple Magento product

Programmatically (manually) creating simple Magento product

In a development process, you often need some testing data you can use. Magento supplies you with it’s default Sample Data that contains some products. Thing is, they’re not of much use if you have some custom attributes added to your products, if you create your own attribute set, or a product type.

Read more

Programmatically adding new customers to the Magento store

Programmatically adding new customers to the Magento store

Us developers love adding things programmatically. Even though you can create a new customer through a signup form, or via admin interface, in some cases, that might take too long.

If you need a bunch of customers assigned to different groups, from different countries, you might be better off doing this from the code.

Read more

Get rewritten product url in a different store

Get rewritten product url in a different store

It was pointed out to me in one of the preceding articles that getting a product’s URL in a different store can get pretty complicated if the URL you want to get is rewritten. I decided to come up with a solution to that problem, as it could be useful in the future.

I came up with a method that returns a rewritten part (i.e. after rewrite) of a product’s URL. You’ll need to add base URL of a store to this return value to get a full URL (as shown on languages.phtml example).

Read more

Show product thumbnail in grids

Show product thumbnail in grids

Editing products and changing their position in categories can be quite a task. This is especially true when you have a large number of products to edit or arrange, and some of them are very similar.

Sure, you could differentiate them by SKU, ID, price, or something else. But wouldn’t it be great if you had a thumbnail of each product in grid?

Read more

Custom category menu navigation in Magento

Custom category menu navigation in Magento

Magento has its top menu reserved for category navigation. It’s pretty solid for displaying categories, even when there is a large number of them.

What some of the clients want is a vertical (sidebar) category menu, so they can display sibling categories of a category their customers are exploring.

In this article we’ll cover the creation of a full vertical menu. We’ll go 3 levels deep: category, subcategory, and sub-subcategory. You can always expand on this, but I believe 3 levels are more than enough for most stores.

Read more

Advanced search in Magento and how to use it in your own way

Advanced search in Magento and how to use it in your own way

Magento’s default catalog search can be a powerful tool. It’s versatility is something every customer can appreciate.

One of the coolest features of the built-in advanced search is the ability to search by attributes assigned to a product. But what if your client’s plans for search are a bit different, and advanced search is too cluttered for his or her needs?

Let’s say your client wants his customers to be able to search by brand or SKU, with all other fields removed from the search, and wishes for custom URL for each one of those search types.

Read more

Filter order grid by multiple ID’s

Filter order grid by multiple ID’s

We all know how great Magento grids can be – there is no alternative when it comes to displaying data in a efficient manner.

Our clients sometimes (almost always) have specific requirements when it comes to Magento. One of them had a request to be able to filter the order grid by multiple order ID’s.

This can be useful if you have a number of orders you’d like to track – filtering them one by one can be tedious and time-consuming task.

Read more

Display product’s rating beyond the review page

Display product’s rating beyond the review page

Reviews are another one of numerous excellent features in Magento. Usage of reviews can increase visitors’ trust in your brand, which, in return boosts your sales by a significant amount.

Sometimes there is a need for showing star ratings outside the products’ review page. That’s what I’ll be addressing with this article.

Read more

Utilizing Magento notification system

notifications-featured

Building your own Magento modules (extensions) can be a tedious task. We always strive to develop everything ‘the Magento way’, which is why we frequently dig into the core to see how Magento’s Core team does things. Once in a while, we stumble upon useful features we think are useful and share them with you. One of such features is Magento’s notification system.

Read more

Programmatically add a custom block in Magento Admin

Programmatically add a custom block in Magento Admin

Howdy! Recently I was in doubt about how to add custom Magento Block for my client’s requirements. One approach was to deal with it through .xml file, but when I was thinking about it I asked myself: “ Why add another .xml and load it?” And at this point, I decided to go with programmatic method.

Read more

Magento functional testing with casper.js

Magento functional testing with casper.js

Testing can be boring and time consuming task. So why don’t we use some tools and make our lives easier? In Magento there are numerous “boring” tasks that need to be done after the first install and then again when you test a new functionality. For example, create a test account, add product to cart, go trough checkout process, add product to wishlist, compare etc.

Read more

PHP shell scripts for Magento

PHP shell scripts for Magento

There are times when it’s necessary to access Magento system from outside Magento. A way to do this is using PHP shell script that bootstraps Magento. An average PHP developer would just go to Magento root directory to create Magento bootstrap file with it’s own code at the bottom. As you’ve probably guessed, there are two ways to bootstrap Magento, regular way and Magento way. In this article I’ll provide an overview of Magento way of creating PHP shell scripts.

Read more

How to add custom product relations in Magento

How to add custom product relations in Magento

Currently there are three types of product relations in Magento: Up-sells, Related Products, and Cross-sell Products. Recently while discussing client’s requirements, we’ve come to conclusion it would serve our purpose best to link products in the same way Magento does, and then use our own relations independently of Magento’s built in product relations. In this article I’ll show you how to add custom product relations as addition to existing Magento product relations.

Read more

Overriding Magento blocks, models, helpers and controllers

Overriding Magento blocks, models, helpers and controllers

There is no project that uses framework as is. Every now and then there is a need to change something, to add something new or to override something already written. Due to many reasons it’s a bad habit and bad programming if core files are modified and it’s not recommended at all. Therefore Magento brought in an excellent way how to override/overwrite those files.

Read more