How to programmatically create a configurable Magento 2 product

- Magento 2

Magento 2 Development

If the simple and configurable products are not assigned together like in the folowing example, there is a reliable solution.

You can review on API functional test aimed at creating configurable product. You code should have the following look:

It is also necessary to mention that the API does not generate simple product, so there is the need to create in advance.

More tips from Magento 2 Developer’s Cookbook

Continue Reading

Adding a custom block to specific product type view pages in Magento 2

- Magento 2

Magento 2 Development

To add a custom block to specific product type view pages, use product type dependent layout updates catalog_product_view_type_{prodyct_type}.xml (catalog_product_view_type_ grouped.xml). For instance:

More tips from Magento 2 Developer’s Cookbook

Continue Reading

How Can I move a search bar in Navigation div in Magento 2 via XML?

- Magento 2

Magento 2 Development

You can put a search box after the navigation block and use css to make display it in one line, since html/topmenu.phtml block doesn’t print its child’s

Alternatively, you can overwrite html/topmenu.phtml to

More tips from Magento 2 Developer’s Cookbook

Continue Reading

How to Generate constructors in Magento 2

- Magento 2

Magento 2 Development

Because of Dependency Injection pattern Magento 2 have huge constructors for every class. World best PHP IDE PHP Storm can help you generate constructors and save lots of time in Magento 2 development.

With constructor generator you will be able to create constructors with arguments, with the value assigned to the field variables. Continue Reading