·

magento 2

Customer Sessions, the Depersonalizer and caching in Magento 2

So recently I had this task… To make a long story short: In Magento you can do every thing in ten different ways. One of the ways of solving my task was by adding a CSS class to the body-tag, but only when the customer is logged in. Now one of the cool things about read further ...

Add a Custom Renderer to the Webapi of Magento 2

So I recently asked an interesting question on Magento Stack Exchange, because I was running in a problem: I was given the task to export a plain TXT list with SKU’s and a status of some sort. I wanted to be cool and learn something new so I decided to utilize Magentos’ web API functionality read further ...

Source Models in Magento 2 and their configuration path

Hi there! Got Magento 2 open in your IDE? Good! Take a look at the <section id="sales_email">-node in the etc/adminhtml/system.xml of the Sales module. Notice anything… weird? Look at all the source models responsible for rendering e-mail templates. They all use the same source model: Magento\Config\Model\Config\Source\Email\Template. This might look weird at first. After all: when read further ...

Customer Tax and Discount Rules

Even though I’ve been working with Magento for some years now, the combination of discount rules and tax rules has always been some kind of mathematical mystery. In basic, there are 2 parameters: Apply customer tax before or after the discount. Apply discount rules on prices on prices including or excluding tax. The combination of read further ...

How to get the categories linked to a product in Magento 2

This might seem like a no-brainer at first. I mean, come on! We all know we can just do $product->getCategoryIds() and move on from there right? You know, create a collection and stuff… But beware! This is not ‘The Magento Way’ on how to do this. I’ve recently posted an interesting question on Stack Exchange, read further ...

Magento 2 Pools

Magento 2 is packed with a lot of cool design patterns. Most of them you might already know, like dependency injection or interceptors, because they are well-known and well- documented. There are however much more design patterns in Magento 2 that are also worth using. One of these patterns that I use regulary in my read further ...

Import images in Magento 2 – the right way

There are various articles about how to programmatically import images in Magento 2. This method relies solely on service contracts and is in my opinion the “Magento Way” to do it: Note that we don’t copy our image whatsoever, but make use of an ImageContent object. This is a new layer of abstraction in read further ...

Convert an order to a shipment in Magento 2

I’ve recently found a small article on how to convert an order to a shipment in Magento 2, but the code in question was a bit outdated. For example, it leaned heavily on the Object Manager instead of handling it with dependency injection and repositories. For that reason, I rewrote the code a bit to read further ...

Create URL Rewrites in Magento 2

Here’s a quick draft on how to create URL Rewrites in Magento 2: read further ...

1 2 3 4