How to speed up slow Magento indexer process? Maria DB 10.4

Category Products index taking too much time? bin/magento index:reset bin/magento index:reindex Stuck at category products index … Here is the solution if you are using MariaDB 10.4 You need to update options/parameters for your db. If using RDS, edit “DB instance parameter group” that you are using and update these 2 values: optimizer_switch='rowid_filter=off' optimizer_use_condition_selectivity = 1 After these changes, restart your database. In aws, RDS automatically updates these parameters without any downtime or requirement for restarting. You will see noticeable difference in indexer time. ...

September 8, 2023 · 1 min · Harshvardhan Malpani

Condition types for addAttributeToFilter in Magento2 Collections

'eq' => "{{column}} = ?", 'finset' => "FIND_IN_SET(?, {{column}})", 'from' => "{{column}} >= ?", 'gt' => "{{column}} > ?", 'gteq' => "{{column}} >= ?", 'in' => "{{column}} IN(?)", 'is' => "{{column}} IS ?", 'like' => "{{column}} LIKE ?", 'lt' => "{{column}} < ?", 'lteq' => "{{column}} <= ?", 'neq' => "{{column}} != ?", 'nin' => "{{column}} NOT IN(?)", 'nlike' => "{{column}} NOT LIKE ?", 'notnull' => "{{column}} IS NOT NULL", 'ntoa' => "INET_NTOA({{column}}) LIKE ?", 'null' => "{{column}} IS NULL", 'regexp' => "{{column}} REGEXP ?", 'seq' => null, 'sneq' => null, 'to' => "{{column}} <= ?"

March 3, 2022 · 1 min · Harshvardhan Malpani

How to fix Magento2 apis not working? fix coupon apis and other PUT OPTIONS APIs

The issue is actually related to your server’s configuration. By default all types of requests are not allowed. Please add the following to your .htaccess file <Limit GET POST OPTIONS PUT DELETE PROPFIND> Order allow,deny Allow from all Require all granted </Limit>

September 26, 2021 · 1 min · Harshvardhan Malpani

How to fix Invalid template file error in Magento2 after version upgrade?

This is a very common issue you will face if you using windows machine for development. Usual error message is: Invalid template file: '/vendor/magento/module-theme/view/frontend/templates/page/js/require_js.phtml' in module: '' block's name: 'require.js' So whats the solution? In case of windows, just replace this function isPathInDirectories in vendor/magento/framework/view/element/template/file/validator.php protected function isPathInDirectories($path, $directories) { $realPath = str_replace('\\', '/', $this->fileDriver->getRealPath($path)); if (!is_array($directories)) { $directories = (array)$directories; } foreach ($directories as $directory) { if (0 === strpos($realPath, $directory)) { return true; } } return false; } Reference: https://magento.stackexchange.com/a/255585/32283

July 26, 2021 · 1 min · Harshvardhan Malpani

How to update customer password in Magento 2 database?

UPDATE `customer_entity` SET `password_hash` = CONCAT(SHA2('SaltPASSWORD', 256), ':SALT:1') WHERE `entity_id` = 7615; Please note that if SPJ9WIp7 is the salt and User’s password is 7qLzX33ETxYE, the following will be your query: UPDATE `customer_entity` SET `password_hash` = CONCAT(SHA2('SPJ9WIp77qLzX33ETxYE', 256), ':SPJ9WIp7:1') WHERE `entity_id` = 7615; 7615 is the customer id

June 12, 2021 · 1 min · Harshvardhan Malpani

Installing a testing instance for Magento CLI only

Prerequisite: Magento repo access keys Mysql Database, username and password a domain name pointing to a server if you dont have access key, get a pair here : https://marketplace.magento.com/customer/accessKeys/\ php -d memory_limit=-1 /bin/composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition=2.2.11 ./ In the above command, you can change version/subversion of magento repo. You can also change the install directory After the successful run of above command:\ bin/magento setup:install \ --base-url=https://testmagento.domain.com \ --db-host=localhost \ --db-name=testmage_x1 \ --db-user=testmage_x1 \ --db-password=WEux3dxxxxw \ --admin-firstname=xxx \ --admin-lastname=yyy \ [email protected] \ --admin-user=admin \ --admin-password=WwKhxxxxxxEK \ --language=en_US \ --currency=USD \ --timezone=America/Chicago \ --use-rewrites=1 YOu will see Magento Admin URI: /admin_10lf7y after successful run ...

February 4, 2021 · 1 min · Harshvardhan Malpani

How to migrate Customers from Magento2 to WordPress?

Lets break it into 2 parts: a. Migrate Customer data b. Migrate Customer Passwords 1) Migrate Customer Data from Magento2 to WordPress This is rather easy to be honest, there are several plugins for importing data from CSV and then mapping the CSV fields. My recommended plugin is Customer/Order/Coupon CSV Import Suite by SkyVerge It basically does everything from customer email to customer address data. It also provides column mapping and custom attribute import for all users. Also comes with multiple configuration options. ...

January 1, 2020 · 2 min · Harshvardhan Malpani

Convert dropdown attribute to text swatch in Magento2 Admin Panel

Run the following code in console: $=new jQuery.noConflict(); $("#swatch-text-options-panel tr td:nth-child(4) input").each(function (e,el) { $(this).parent().parent().find("td:nth-child(3) input").val($(this).val());});

September 24, 2019 · 1 min · Harshvardhan Malpani

How to change attribute dropdown type to multi-select in Magento 2?

Short Answer: Not possible via Magento2 Admin Backend. Solution: You need to update eav_attribute table and edit information about backend_source, frontend_input etc. Simple query for that is: UPDATE `eav_attribute` SET `backend_model`="Magento\\\Eav\\\Model\\\Entity\\\Attribute\\\Backend\\\ArrayBackend", `backend_type`="varchar", `frontend_input`="multiselect", `source_model`=NULL WHERE `attribute_id`=YOUR_ATTRIBUTE_ID_INTEGER LIMIT 1 Replace YOUR_ATTRIBUTE_ID_INTEGER with your attribute_id like 355 Reference: https://stackoverflow.com/a/57701845/2229148

August 29, 2019 · 1 min · Harshvardhan Malpani

How to disable products in Magento2 which dont have any gallery image?

UPDATE `catalog_product_entity_int` SET `value`=2 where `entity_id` in (SELECT a.`entity_id` FROM `catalog_product_entity` AS a LEFT JOIN `catalog_product_entity_media_gallery_value` AS b ON a.entity_id = b.entity_id LEFT JOIN `catalog_product_entity_media_gallery` AS c ON b.value_id = c.value_id WHERE c.value IS NULL) and `attribute_id` = 96 It is SQL query Assumption: value=2 means disable and value=1 means enable attribute_id=96 means “status” attribute References: https://gist.github.com/tegansnyder/8464261#gistcomment-2910808 https://magento.stackexchange.com/a/83033/32283

August 22, 2019 · 1 min · Harshvardhan Malpani