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

Magento 2 cli commands [continued]

1. Setting GD2 as defualt image adapter from command line Magento >= 2.2 php bin/magento config:set dev/image/default_adapter GD2 php bin/magento cache:clean Magento >= 2.2 mysql --host=(host) --user=(user) --password=(password) -D (database) -e "\ UPDATE core_config_data SET value = 'GD2' WHERE 'dev/image/default_adapter' = path; \"; 2. Disable Minify CSS Files option from command line Magento >= 2.2 php bin/magento config:set dev/css/minify_files 0 php bin/magento cache:clean Magento < 2.2 mysql --host= --user= --password= -D -e "\ UPDATE core_config_data SET value = 0 WHERE 'dev/css/minify_files' = path; \"; php bin/magento cache:clean 3. Disable Merge CSS Files option from command line php bin/magento config:set dev/css/merge_css_files 0 php bin/magento cache:clean Magento < 2.2 mysql --host= --user= --password= -D -e "\ UPDATE core_config_data SET value = 0 WHERE 'dev/css/merge_css_files' = path; \"; php bin/magento cache:clean

August 1, 2018 · 1 min · Harshvardhan Malpani

How to install theme in Magento 2

Download the theme and copy the app folder and paste it in your magento root directory Open Shell, in the root directory, enter ***php bin/magento setup:upgrade .***This will upgrade all the magento files. Also, Clear cache ,type php bin/magento cache:clean . Now force deploy the static files by typing ***php bin/magento setup:static-content:deploy -f .***It will take a while. Now, Go in the dashboard and select content->configuration. ...

July 29, 2018 · 1 min · Harshvardhan Malpani

Magento File Directory

/app The etc folder contains the di.xml configuration file The di.xml file contains class mapping and interface preferences Contains the design folder for themes. /bin The directory contains the magento file or a Command Line Interface script /dev Magento 2 testing and development tools are placed in this folder. /lib The internal and web subfolders are located here The internal directory contains server-side libraries and several font files; The web subfolder contains client-side libraries, jquery, modernizr, requirejs, prototype, scriptaculous ...

July 27, 2018 · 1 min · Harshvardhan Malpani

[SOLVED] Magento 2 Error: A technical problem with the server created an error. Try again to continue what you were doing. If the problem persists, try again later.

Sometimes debugging on Magento can be annoying, specially if something just arises out of the blue, not while you are actually writing a code. This is something that occurs on Magento admin panel. As of now, it can be one out of 3 reasons, let us discuss them: 1. Admin Password Try to change admin password, log out and log in again. This should fix it. ...

March 15, 2018 · 1 min · Harshvardhan Malpani

Magento 2 : How to fix tablespace for table exists | base table or view already exists

Fixing General error: 1813 Tablespace for table xx Please DISCARD the tablespace before IMPORT and SQLSTATE[42S01]: Base table or view already exists\ Recently I encountered this error while upgrading an extension on Magento 2.2.2 The error was SQLSTATE[HY000]: General error: 1813 Tablespace for table '`jack_db1`.`jill_table`' exists. Please DISCARD the tablespace before IMPORT., query was: CREATE TABLE IF NOT EXISTS `jill_table` When I tried to fix the above error, I received: ...

February 26, 2018 · 2 min · Harshvardhan Malpani

Magento 2 how to show configurable options stock availability on product page

addtocart.phtml <?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ // @codingStandardsIgnoreFile /** @var $block \Magento\Catalog\Block\Product\View */ ?> <?php $_product = $block->getProduct(); ?> <?php $buttonTitle = __('Add to Cart'); ?> <?php if ($_product->isSaleable()): ?> <div class="box-tocart"> <div class="fieldset"> <?php if ($block->shouldRenderQuantity()): $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $StockState = $objectManager->get('\Magento\CatalogInventory\Api\StockStateInterface');?> <div class="field qty"> <label class="label" for="qty"><span><?= /* @escapeNotVerified */ __('Qty') ?></span></label> <div class="control"> <?php if($_product->getTypeId()=="simple") { ?> <select class="input-text qty" name="qty" id="qty" data-validate="<?= $block->escapeHtml(json_encode($block->getQuantityValidators())) ?>"> <?php $availableQty= $StockState->getStockQty($_product->getId(), $_product->getStore()->getWebsiteId()); for($repli=1;$repli<=$availableQty;$repli++) echo "<option value='$repli'>$repli</option>"; ?> </select> <?php } else { $usedProducts = $_product->getTypeInstance()->getUsedProducts($_product); $productStockd=$objectManager->get('Magento\CatalogInventory\Api\StockRegistryInterface'); $finalconfigqty=[]; foreach ($usedProducts as $child) {$childid=$child->getId(); $productStockObj = $productStockd->getStockItem($childid); $availableQty= round($productStockObj->getData('qty')); $finalconfigqty['c'.$childid]=$availableQty; } echo '<script> var fichoo='. json_encode($finalconfigqty). '</script>'; echo '<select class="input-text qty fichoo" name="qty" id="qty"><option value=1>1</option></select>'; ?> <!--input type="number" name="qty" id="qty" value="<?= $block->getProductDefaultQty() * 1 ?>" title="<?= __('Qty') ?>" class="input-text qty" data-validate="<?= $block->escapeHtml(json_encode($block->getQuantityValidators())) ?>" /--> <?php } ?> </div> </div> <?php endif; ?> <div class="actions"> <button type="submit" title="<?= /* @escapeNotVerified */ $buttonTitle ?>" class="action primary tocart" id="product-addtocart-button"> <span><?= /* @escapeNotVerified */ $buttonTitle ?></span> </button> <?= $block->getChildHtml('', true) ?> </div> </div> </div> <?php endif; ?> <?php if ($block->isRedirectToCartEnabled()) : ?> <script type="text/x-magento-init"> { "#product_addtocart_form": { "Magento_Catalog/product/view/validation": { "radioCheckboxClosest": ".nested" } } } </script> <?php else : ?> <script type="text/x-magento-init"> { "#product_addtocart_form": { "Magento_Catalog/js/validate-product": {} } } </script> <?php endif; ?> Another important file is Magento_ConfigurableProduct/web/js/configurable.js ...

February 16, 2018 · 9 min · Harshvardhan Malpani

Magento 2 temporary fix for Alphabetical sorting of Configurable product options

Just re-write the file vendor/magento/module-configurable-product/Model/ConfigurableAttributeData.php <?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ namespace Magento\ConfigurableProduct\Model; use Magento\Catalog\Model\Product; use Magento\ConfigurableProduct\Model\Product\Type\Configurable\Attribute; /** * Class ConfigurableAttributeData * @api * @since 100.0.2 */ class ConfigurableAttributeData { /** * Get product attributes * * @param Product $product * @param array $options * @return array */ public function getAttributesData(Product $product, array $options = []) { $defaultValues = []; $attributes = []; foreach ($product->getTypeInstance()->getConfigurableAttributes($product) as $attribute) { $attributeOptionsData = $this->getAttributeOptionsData($attribute, $options); if ($attributeOptionsData) { $productAttribute = $attribute->getProductAttribute(); $attributeId = $productAttribute->getId(); $attributes[$attributeId] = [ 'id' => $attributeId, 'code' => $productAttribute->getAttributeCode(), 'label' => $productAttribute->getStoreLabel($product->getStoreId()), 'options' => $attributeOptionsData, 'position' => $attribute->getPosition(), ]; $defaultValues[$attributeId] = $this->getAttributeConfigValue($attributeId, $product); } } return [ 'attributes' => $attributes, 'defaultValues' => $defaultValues, ]; } public function labelsort($a,$b){ return strcmp($a['label'], $b['label']);} /** * @param Attribute $attribute * @param array $config * @return array */ protected function getAttributeOptionsData($attribute, $config) { $attributeOptionsData = []; foreach ($attribute->getOptions() as $attributeOption) { $optionId = $attributeOption['value_index']; $attributeOptionsData[] = [ 'id' => $optionId, 'label' => $attributeOption['label'], 'products' => isset($config[$attribute->getAttributeId()][$optionId]) ? $config[$attribute->getAttributeId()][$optionId] : [], ]; } if(count($attributeOptionsData) > 1){usort($attributeOptionsData,array($this,'labelsort'));} return $attributeOptionsData; } /** * @param int $attributeId * @param Product $product * @return mixed|null */ protected function getAttributeConfigValue($attributeId, $product) { return $product->hasPreconfiguredValues() ? $product->getPreconfiguredValues()->getData('super_attribute/' . $attributeId) : null; } }

February 16, 2018 · 2 min · Harshvardhan Malpani

How to update Magento community edition using CLI

composer require magento/product-community-edition 2.2.6 --no-update composer update rm -rf var/di var/generation var/cache var/view_preprocessed generated/* php bin/magento cache:clean php bin/magento cache:flush php bin/magento setup:upgrade php bin/magento setup:di:compile php bin/magento indexer:reindex php bin/magento deploy:mode:set production if you receive any errors post installation, try this hard fix rm -rf app/code/Magento/ var/* vendor/* chmod 777 -R * composer update && composer install php -f bin/magento setup:static-content:deploy find . -type d -exec chmod 775 {} find . -type f -exec chmod 660 {} chmod u+x bin/magento bin/magento maintenance:disable bin/magento cache:clean

February 1, 2018 · 1 min · Harshvardhan Malpani

How to add custom attributes in Magento 2 product CSV export

Core Method is to edit the file /vendor/magento/module-catalog-import-export/Model/Export/Product.php and Edit the variable $_exportMainAttrCodes Add your attributes in the array like “custom1″,”custom2”, etc and save the file. Next time you export the csv, you will see new columns in the file.

January 25, 2018 · 1 min · Harshvardhan Malpani