If you add a translation to a language CSV file (such as de_DE.csv), it may not be included correctly in your theme’s js-translation.json . Consequently, messages such as validation errors remain untranslated. To fix this, override vendor/magento/module-translation/Model/Json/PreProcessor.php and make the…
Reading an extension version from the database using SQL (Magento 2)
The following SQL query returns the installed version of any Magento 2 extension.
|
1 |
SELECT * FROM setup_module WHERE module='Ihre_Extension'; |
Displaying the search form (form.mini.phtml) in a template (Magento 2)
Use the following code to display the search form form.mini.phtml inside any Magento 2 template.
|
1 |
$this->getLayout()->createBlock('core/template')->setTemplate('catalogsearch/form.mini.phtml')->toHtml(); |
Filtering product collections by category (Magento 2)
If you want to filter a product collection by categories as well, the following code may help. Once the category filter is applied, the collection contains only products from the specified categories, in this example category IDs 123 and 456.…
Detecting the current page type in a model (Magento 2)
The following code lets you determine the current page type (category, product, etc.) from a Magento 2 model:
|
1 |
$where = $this->request->getFullActionName(); |
The value of $where is, for example, catalog_product_viewwhen you are on a Magento product page.
No results on page 2 or subsequent category pages (Magento 2)
If page 2 and subsequent category pages in your Magento 2.3.3 store return no results despite products being available, this may be related to Elasticsearch 6.x. The Magento team has released a patch for this issue. You can find it…
Adjusting VAT rates in 2020 (Magento 1 / 2)
Germany plans to temporarily reduce its VAT rate from 19% to 16% in 2020. If you do not have time, or are unsure how to make this change, I would be happy to help you update your Magento 1 or…
Including one template (phtml) in another template (Magento 2)
To render one .phtml template inside another template, insert the following code at the desired location:
|
1 2 |
// Insert the search field anywhere in a template echo $this->getLayout()->createBlock("Magento\Framework\View\Element\Template")->setTemplate("Magento_Search::form.mini.phtml")->toHtml(); |
Fixing Bad credentials in Extension Manager (Magento 2)
If you receive the error Bad credentials when trying to sign in to the Magento 2 Extension Manager, copy your public and private keys manually from Magento Marketplace and paste them into the Extension Manager. The Marketplace’s copy link sometimes…