This post is part of series: Part 1: Overview Part 2: Request and URI Part 3: Response Part 4: File Uploads Part 5: HTTP-Client Part 6: Server Request Part 7: Middleware Part 8: Usage in a Magento module In the last blog post we described the RequestInterface of PSR-7. Every application will process this request and returns a response to the calling client. The response is the part where a backend sends a result of an server operation back to the client. Let’s view…
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 the server will return JSON as…
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…
This post is part of series: Part 1: Overview Part 2: Request and URI Part 3: Response Part 4: File Uploads Part 5: HTTP-Client Part 6: Server Request Part 7: Middleware Part 8: Usage in a Magento module In the last blog post we described the history of PSR-7. The standard contains only interfaces. Today we start with the first two interfaces. The RequestInterface and the UriInterface. What is a HTTP Request? To start we create a little server simulation script with this content:…
After attending my 10th Meet Magento in Germany (yes I missed one) and coming back to work, I think it is time for a short recap. This years Meet Magento probably was the biggest one in terms of number of attendants (800, according to the organizers). The location was at it’s limits for that amount of people. Luckily the weather was sunny so people could get outside and get some space. The next years Meet Magento will probably / hopefully…
The Imagine: The Magento event as such! To me as an USA newbie on the one hand interesting because the conference takes place in Las Vegas, to me as a frontend developer on the other hand interesting because you can learn much about how Magento itself, but the community as well – like other developers, agencies and webshop operators – are working with the e-commerce platform and continuously developing it further. Let’s start at the beginning: Las Vegas is truly…
It was the second time that I attended the Magento Imagine. Last year the conference was characterized by the motto „We are Magento“. This year the word „E-Commerce Platform“ stays in my mind. Before I start my summary of the conference, I would like to tell a little bit about our trip … We startet our #RoadToImagine from Frankfurt/Main. After a 9h flight we (Maria, Ralf, Alex and me) arrived in Houston (Texas). There we had time to grab some pizzas after a…
I recently had the issue that I needed to use the \Magento\Eav\Setup\EavSetup outside the setup-context. To be a bit more concrete, I wanted to import attribute-sets, attributes and attribute-options without using an install-script. My first idea was in magento2 you can easily inject the ‘EavSetup’ via constructor injection and then use it in your own class First try So I injected into my class which worked out well in the development-mode.
* SomeAttribute constructor.
* @param \Some\Own\AttributeContext $context
* @param \Magento\Eav\Setup\EavSetup $eavSetup
* @param string $entityTypeId
public function __construct(
$entityTypeId = Product::ENTITY
$this->eavSetup = $eavSetup;
$this->entityTypeId = $entityTypeId;
But using the same code with the production-mode a…
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…
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 container or a complete different system. After composer install, n98-magerun2 is available…