Installing Magento Common Issues

Following are the steps to complete install Magento error-free:- Uncomment the files which are required by Magento in php.ini and restart the server If installation error occurs, set memory_limit = 786M if still error occurs, uninstall the db and make it again after successfull install, go to (root_directory)app/etc/di.xml and change “Symlink” to “Copy” in developerMaterialization section. go to cmd , root directory and type :- “/bin/magento setup:static-content:deploy refresh the page. done.

July 22, 2018 · 1 min · Harshvardhan Malpani

Bulk Add Custom Attribute Options in Magento 1

$jq=new jQuery.noConflict(); var mimim=["Yellow Topaz", "Alexandrite"]; $jq.each(mimim,function(a,b){ $jq("#add_new_option_button").click(); $jq("#matage-options-panel .dynamic-grid tbody tr:nth-child(2) td:nth-child(1) input").val(b); });

May 16, 2018 · 1 min · Harshvardhan Malpani

Magento 2 – How to manage multi domain website store setup URLs

select * from `core_config_data` where path like 'web/%'

April 3, 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

Remove sku column from Magento 2 invoice and pdf

Edit the file /vendor/magento/module-sales/Model/Order/Pdf/Items/Invoice/DefaultInvoice.php Inside function draw(), remove/comment following code: // draw SKU $lines[0][] = [ 'text' => $this->string->split($this->getSku($item), 17), 'feed' => 290, 'align' => 'right', ]; To remove the SKU header in table header, edit the file /vendor/magento/module-sales/Model/Order/Pdf/Invoice.php 95 //$lines[0][] = ['text' => __('SKU'), 'feed' => 290, 'align' => 'right']; and copy the file vendor/magento/module-sales/view/frontend/templates/email/items/order/default.phtml to app/design/your/theme/Magento_Sales/templates/email/items/order/default.phtml and remove the code <p class="sku"><?= /* @escapeNotVerified */ __('SKU') ?>: <?= $block->escapeHtml($block->getSku($_item)) ?></p>

February 21, 2018 · 1 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

Show Available Stock quantity for each product in Magento 2

<?php $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $StockState = $objectManager->get('\Magento\CatalogInventory\Api\StockStateInterface'); echo $StockState->getStockQty($product->getId(), $product->getStore()->getWebsiteId()); ?> Reference: https://magento.stackexchange.com/a/97952/32283

February 9, 2018 · 1 min · Harshvardhan Malpani

How to shift category description below products in Magento 2

In your theme folder, add Folder Magento_Catalog/layout and in layout folder add file catalog_category_view.xml <?xml version="1.0"?> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="2columns-left" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> <body> <move element="category.view.container" after="content" destination="main.content" /> </body> </page>

January 29, 2018 · 1 min · Harshvardhan Malpani

How to manage Magento 2 product attribute values options using console

This is an update to my previous script which was used to add custom product attribute values using backend – Add values to product attribute Read the previous^ part to get introduction about how it works. you will have to use browser console (ctrl + shift +j in Google chrome) First of all initialize the array mimim with the final set of values you want to see in backend. The script then automatically removes the extra options first(values which are not in mimim but in present in backend), then it adds the remaining values from mimim (which are in mimim but not at backend) ...

November 22, 2017 · 1 min · Harshvardhan Malpani