Browsed by
Category: Magento 2

Create a GraphQL Mesh from scratch

Create a GraphQL Mesh from scratch

GraphQL Mesh is a powerful tool that allows you to use GraphQL query language, regardless of the source’s original format. It can be used with REST APIs, gRPC, SOAP, and more. In this blog post, we’ll explore how to set up and use GraphQL Mesh in your projects. Warning: The article requires a bit of NodeJS knowledge. The examples are tested with NodeJS 16.We also define a environment variable MAGENTO_ACCESS_TOKEN containing a a Magento Bearer Token. to access the API….

Read More Read More

AJAX loading of related products in Magento 2

AJAX loading of related products in Magento 2

Introduction In some projects the amount of related products can be significant. In my case there were more than 300 related products and upsell products on some product detail pages. The consequence of this was a high time to first byte on product detail pages. In the mentioned project it was about 15 seconds for some of the products. So we searched for a possible optimization. We finally decided to implement asynchronous loading of product recommendations via AJAX. At the…

Read More Read More

How a wrong carrier implementation causes a server outage

How a wrong carrier implementation causes a server outage

Sometimes one wrong line of code can break your site. In the following I will describe a mistake in a Magento 2 custom carrier implementation, which causes a massive overloading of server resources (CPU, RAM, DB processes) and even can cause an outage of your Magento store. The one line of code The following line of code is the reason for the problems, if used in the collectRates() method, or in methods, called from collectRates() in the Carrier class: $quote…

Read More Read More

Sequence of Magento 2 Install / Upgrade / Recurring scripts

Sequence of Magento 2 Install / Upgrade / Recurring scripts

Preamble In one of my last tasks I had to write an upgrade script in which an assignment of a newly created frontend theme to some of the stores should be implemented. The following code-part describes what I did here: /** * */ protected function assignNewThemeToSelectedStores() { $storeIdsForNewTheme = []; foreach ($this->storesCodesWithNewTheme as $storeCode) { $storeIdsForNewTheme[] = $this->storeRepository->get($storeCode)->getId(); } /** @var \Magento\Theme\Model\ResourceModel\Theme\Collection $themes */ $themes = $this->themeCollectionFactory->create()->loadRegisteredThemes(); /** * @var \Magento\Theme\Model\Theme $theme */ foreach ($themes as $theme) { if ($theme->getCode()…

Read More Read More

Get PDF files by Magento Webapi

Get PDF files by Magento Webapi

Magento 2 comes with a modern REST interface. One of the advantages of the REST interface is that it can handle multiple response types. A client can request data from the server with a list of acceptable response formats. Out of the box Magento 2 supports two types. It comes with JSON and XML support. You can test it with a simple call to your local store. curl -X GET –header “Accept: application/json” “http://<store-baseurl>/rest/default/V1/categories” If you omit the accept header…

Read More Read More

Think outside the box: Magento 2 as API framework

Think outside the box: Magento 2 as API framework

In this article, we will cover the web-API and how to use Magento 2 as a standalone API-framework. If the web-API is new to you, I recommend to read the development documentation of it first: Magento 2 API documentation Why should I do this? Short answer: Because you can! Not really, there is no reason why you shouldn’t try it at least and have some fun with it – you might get used to it 😉 With Magento 2, the…

Read More Read More

Use Swagger to generate a full functional Magento API Client

Use Swagger to generate a full functional Magento API Client

Magento 2 comes with a nice swagger schema which describes the Webapi. The Magento guys were very clever to choose swagger. It not only comes with a schema, but moreover it is a complete interactive API client as well. A swagger schema is a JSON document to formalize the REST API. Formalized documents have the big advantage that you can process the data with a machine. One idea I had was to create a PHP API for the Magento 2 API. Fortunately the swagger…

Read More Read More

Nice to know: Install N98-Magerun via Composer

Nice to know: Install N98-Magerun via Composer

There is a so far merely undocumented installation procedure for Magerun that is extremely handy in project configurations. You just require Magerun within the Magento project and you can then execute it from the vendor’s bin folder: $ composer require n98/magerun2 […] $ ./vendor/bin/n98-magerun2 –version n98-magerun2 version 1.3.2 by netz98 GmbH Afterwards if you commit the composer.json  and composer.lock  files it is a take-away for the whole team. So it is regardless whether you’re running it locally, inside a docker…

Read More Read More

Introducing MageDeploy2

Introducing MageDeploy2

In our recent post series about Deploying Magento2 using Jenkins and deployer I was showing you how our Deployments are set up. In case you haven’t read them and are interested in the details here are the links: History and Overview of Magento2 Deployment Jenkins Build-Pipeline Setup (building assets, controlling the deployment) Releasing to Production (delivering code and assets, managing releases) Future Prospect (cloud deployment, artifacts) During the time of writing those articles I realized quite some improvements and generalizations that could be…

Read More Read More

Deploying Magento2 – Future Prospects [4/4]

Deploying Magento2 – Future Prospects [4/4]

This post is part of series: History and Overview of Magento2 Deployment Jenkins Build-Pipeline Setup (building assets, controlling the deployment) Releasing to Production (delivering code and assets, managing releases) Future Prospect (cloud deployment, artifacts) Recap In the previous posts we dived into our Deployment Pipeline and the Release to the staging or production environments. You should check those posts first before reading this one. In this post we will share our thoughts on where we want to go with our…

Read More Read More