Category Archives: Uncategorized

July 18, 2018 6:34 pm
image_round

(Solved) Magento 2 add to cart configurable product adding item twice – 2 times

Magento ver. 2.2.4

Magento 2 white adding item to cart (configurable product) once its sending add to cart ajax twice so minicart showing double items

Solution:
#1 disable Amazon module

php bin/magento module:disable Amazon_Core Amazon_Login Amazon_Payment

#2
Comment below line code

self.submitForm($(this));
this._bindSubmit();

in  \vendor\amzn\amazon-pay-and-login-magento-2-module\src\Payment\view\frontend\web\js\catalog-add-to-cart.js

(Solved) Magento 2 add to cart configurable product adding item twice – 2 times

Magento ver. 2.2.4

Magento 2 white adding item to cart (configurable product) once its sending add to cart ajax twice so minicart showing double items

Solution:
#1 disable Amazon module

php bin/magento module:disable Amazon_Core Amazon_Login Amazon_Payment

#2
Comment below line code

self.submitForm($(this));
this._bindSubmit();

in  \vendor\amzn\amazon-pay-and-login-magento-2-module\src\Payment\view\frontend\web\js\catalog-add-to-cart.js

November 30, 2016 6:40 am
image_round

How to add drop down system config tab in magento 2

<!----Introduction
Youre Company name = Ngage
Your Module name  = Testimonial --->

youre pathe is generate like this
app/code/Ngage/Ngage/etc/adminhtml/system.xml
app/code/Ngage/Ngage/Model/Config/Source/ListMode.php



Step 1 
first create system.xml file in following path
--> app/code/YourCompanyname/Modulename/etc/adminhtml/system.xml
-->copy past following code in your system.xml file
  
    <field id="list_mode" translate="label" type="select" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1">
        <label>List Mode</label>
        <source_model>Companyname\Modulename\Model\Config\Source\listmode</source_model>
    </field>
------End step 1 ----------	
------Start Step 2 -------	
After then following Step 2


Create source model file in following path
app\code\Companyname\Modulename\Model\Config\Source\ListMode.php
--> copy past following code in your listmode.php

<?php 
  
namespace Companyname\Modulename\Model\Config\Source;	
class ListMode implements \Magento\Framework\Option\ArrayInterface
    {
    /**
     * {@inheritdoc}
     *
     * @codeCoverageIgnore
     */
    public function toOptionArray()
    {
        return [
            ['value' => 'grid', 'label' => __('Grid Only')],
            ['value' => 'list', 'label' => __('List Only')],
            ['value' => 'Slider', 'label' => __('Slider')],
        ];
    } 
    } 
  
?>

 
Free Download Module Magento 2 Ngage Studios

How to add drop down system config tab in magento 2

<!----Introduction
Youre Company name = Ngage
Your Module name  = Testimonial --->

youre pathe is generate like this
app/code/Ngage/Ngage/etc/adminhtml/system.xml
app/code/Ngage/Ngage/Model/Config/Source/ListMode.php



Step 1 
first create system.xml file in following path
--> app/code/YourCompanyname/Modulename/etc/adminhtml/system.xml
-->copy past following code in your system.xml file
  
    <field id="list_mode" translate="label" type="select" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1">
        <label>List Mode</label>
        <source_model>Companyname\Modulename\Model\Config\Source\listmode</source_model>
    </field>
------End step 1 ----------	
------Start Step 2 -------	
After then following Step 2


Create source model file in following path
app\code\Companyname\Modulename\Model\Config\Source\ListMode.php
--> copy past following code in your listmode.php

<?php 
  
namespace Companyname\Modulename\Model\Config\Source;	
class ListMode implements \Magento\Framework\Option\ArrayInterface
    {
    /**
     * {@inheritdoc}
     *
     * @codeCoverageIgnore
     */
    public function toOptionArray()
    {
        return [
            ['value' => 'grid', 'label' => __('Grid Only')],
            ['value' => 'list', 'label' => __('List Only')],
            ['value' => 'Slider', 'label' => __('Slider')],
        ];
    } 
    } 
  
?>

 
Free Download Module Magento 2 Ngage Studios

July 8, 2016 1:49 pm
image_round

how to get skin url path magento 2

{{view url=''}} // In Block and CMS Pages

$block->getViewFileUrl() // in Phtml or on php

how to get skin url path magento 2

{{view url=''}} // In Block and CMS Pages

$block->getViewFileUrl() // in Phtml or on php
June 4, 2016 1:26 pm
image_round

Magento 2: How to get custome attribute ?

 

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$_product = $objectManager->get('Magento\Catalog\Model\Product')->load($_item->getProduct()->getId());

<?php 
      $attr = $_product->getResource()->getAttribute('brand');
      if ($attr->usesSource()) {
        $optionText = $attr->getSource()->getOptionText($_product->getBrand()); ?>
      <div class="brand">
        <span><?php echo $optionText; ?></span>
      </div>
    <?php 	} ?>

 

 

Magento 2: How to get custome attribute ?

 

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$_product = $objectManager->get('Magento\Catalog\Model\Product')->load($_item->getProduct()->getId());

<?php 
      $attr = $_product->getResource()->getAttribute('brand');
      if ($attr->usesSource()) {
        $optionText = $attr->getSource()->getOptionText($_product->getBrand()); ?>
      <div class="brand">
        <span><?php echo $optionText; ?></span>
      </div>
    <?php 	} ?>

 

 

June 4, 2016 1:24 pm
image_round

Magento 2 : How to get product image ?

Follow this Code .

<?php
  $objectManager = \Magento\Framework\App\ObjectManager::getInstance();
  $_product = $objectManager->get('Magento\Catalog\Model\Product')->load($_item->getProduct()->getId());

    $image = 'wishlist_thumbnail';
    $_imagehelper = $this->helper('Magento\Catalog\Helper\Image');
    $productImage = $_imagehelper->init($_product, $image)->constrainOnly(FALSE)->keepAspectRatio(TRUE)->keepFrame(FALSE)->resize(200)->getUrl();
?>
<img src="<?php echo $productImage; ?>" alt="<?php echo $_product->getName() ?>" />

Magento 2 : How to get product image ?

Follow this Code .

<?php
  $objectManager = \Magento\Framework\App\ObjectManager::getInstance();
  $_product = $objectManager->get('Magento\Catalog\Model\Product')->load($_item->getProduct()->getId());

    $image = 'wishlist_thumbnail';
    $_imagehelper = $this->helper('Magento\Catalog\Helper\Image');
    $productImage = $_imagehelper->init($_product, $image)->constrainOnly(FALSE)->keepAspectRatio(TRUE)->keepFrame(FALSE)->resize(200)->getUrl();
?>
<img src="<?php echo $productImage; ?>" alt="<?php echo $_product->getName() ?>" />
June 4, 2016 8:38 am
image_round

Magento 2 : How to add custom logs

$_product = $this->item->getProduct();
$writer = new \Zend\Log\Writer\Stream(BP . '/var/log/test.log');
$logger = new \Zend\Log\Logger();
$logger->addWriter($writer);
$logger->info(print_r($_product->getData(), true));

Magento 2 : How to add custom logs

$_product = $this->item->getProduct();
$writer = new \Zend\Log\Writer\Stream(BP . '/var/log/test.log');
$logger = new \Zend\Log\Logger();
$logger->addWriter($writer);
$logger->info(print_r($_product->getData(), true));
June 2, 2016 9:38 am
image_round

Magento 2 : How to add add custom link to toplinks

<referenceBlock name="top.links">
<block class="Magento\Framework\View\Element\Html\Link\Current" name="contact-us">
<arguments>
<argument name="label" xsi:type="string">Contact Us</argument>
<argument name="path" xsi:type="string">contact-us</argument>
</arguments>
</block>
</referenceBlock>

Magento 2 : How to add add custom link to toplinks

<referenceBlock name="top.links">
<block class="Magento\Framework\View\Element\Html\Link\Current" name="contact-us">
<arguments>
<argument name="label" xsi:type="string">Contact Us</argument>
<argument name="path" xsi:type="string">contact-us</argument>
</arguments>
</block>
</referenceBlock>
June 1, 2016 9:52 am
image_round

Magento 1.x fix Product Flat Data reindexing issue with row size too large

When you get some error like this

Product Flat Data index process unknown error: exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1118 Row size too large.
The maximum row size for the used table type, not counting BLOBs, is 65535.
You have to change some columns to TEXT or BLOBs'

Then you just have to update one file and 2 lines

app/code/core/Mage/Eav/Model/Entity/Attribute/Abstract.php, decreasing the value of the length element on line 604 from 255 characters to 64 in the following array:

$columns[$this->getAttributeCode()] = array(
   'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
   'length' => '64',
   'unsigned' => false,
   'nullable' => true,
   'default' => null,
   'extra' => null
);

and  Decrease the value of the type element on line 677  from 255 characters to 64 in the following array:

$columns[$this->getAttributeCode()] = array(
   'type' => 'varchar(64)',
   'unsigned' => false,
   'is_null' => true,
   'default' => null,
   'extra' => null
);

Magento 1.x fix Product Flat Data reindexing issue with row size too large

When you get some error like this

Product Flat Data index process unknown error: exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1118 Row size too large.
The maximum row size for the used table type, not counting BLOBs, is 65535.
You have to change some columns to TEXT or BLOBs'

Then you just have to update one file and 2 lines

app/code/core/Mage/Eav/Model/Entity/Attribute/Abstract.php, decreasing the value of the length element on line 604 from 255 characters to 64 in the following array:

$columns[$this->getAttributeCode()] = array(
   'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
   'length' => '64',
   'unsigned' => false,
   'nullable' => true,
   'default' => null,
   'extra' => null
);

and  Decrease the value of the type element on line 677  from 255 characters to 64 in the following array:

$columns[$this->getAttributeCode()] = array(
   'type' => 'varchar(64)',
   'unsigned' => false,
   'is_null' => true,
   'default' => null,
   'extra' => null
);
May 23, 2016 5:02 pm
image_round

Magento 2: How to delete all cached and generated files

Magento 2: How to delete all cached and generated files

The script need to be executed in Magento 2 root folder.

It deletes all the contents of var subfolder except var/session subfolder and except the.htaccess file

It deletes all the contents of pub/static subfolder except the.htaccess file

find var/* -type f -or -type d | grep -v 'session' | xargs rm -rf && \
rm -rf pub/static/*

Magento 2: How to delete all cached and generated files

Magento 2: How to delete all cached and generated files

The script need to be executed in Magento 2 root folder.

It deletes all the contents of var subfolder except var/session subfolder and except the.htaccess file

It deletes all the contents of pub/static subfolder except the.htaccess file

find var/* -type f -or -type d | grep -v 'session' | xargs rm -rf && \
rm -rf pub/static/*
May 18, 2016 1:50 pm
image_round

Magento 2 : how to get Product select attribute option value on product page

Step 1: Add Block for an attribute on catalog_product_view.xml

<block class="Magento\Catalog\Block\Product\View\Description" name="page.main.brand" template="Magento_Catalog::product/view/brand.phtml">
      	<arguments>
        <argument name="at_call" xsi:type="string">getBrand</argument>
        <argument name="at_code" xsi:type="string">brand</argument>
        <argument name="css_class" xsi:type="string">brand</argument>
        <argument name="at_label" xsi:type="string">default</argument>
        <argument name="add_attribute" xsi:type="string">itemprop="brand"</argument>
      </arguments>
      </block>

 

Step 2: move it to your location

<move element="page.main.brand" destination="product.info.main" after="page.main.title"/>

Step 3 : udpate phtml file with your custom html and code

<?php
/**
 * Copyright © 2016 Magento. All rights reserved.
 * See COPYING.txt for license details.
 */

// @codingStandardsIgnoreFile

/**
 * Product description template
 *
 * @var $block \Magento\Catalog\Block\Product\View\Description
 */
?>
<?php
$_helper = $this->helper('Magento\Catalog\Helper\Output');
$_product = $block->getProduct();
 
$_code = $block->getAtCode();
$_className = $block->getCssClass();
$_attributeLabel = $block->getAtLabel();
$_attributeType = $block->getAtType();
$_attributeAddAttribute = $block->getAddAttribute();
 
if ($_attributeLabel && $_attributeLabel == 'default') {
$_attributeLabel = $_product->getResource()->getAttribute($_code)->getFrontendLabel();
}
 
$_attributeValue =$_product->getResource()->getAttribute($_code)->getFrontend()->getValue($_product);
 
?>
 
<?php if ($_attributeValue): ?>
<div class="product attibute <?php echo $_className?>">
<?php /*?><?php if ($_attributeLabel != 'none'): ?><strong class="type"><?php echo $_attributeLabel?></strong><?php endif; ?><?php */?>
<div class="value" <?php echo $_attributeAddAttribute;?>><?php echo $_attributeValue; ?></div>
</div>
<?php endif; ?>

Magento 2 : how to get Product select attribute option value on product page

Step 1: Add Block for an attribute on catalog_product_view.xml

<block class="Magento\Catalog\Block\Product\View\Description" name="page.main.brand" template="Magento_Catalog::product/view/brand.phtml">
      	<arguments>
        <argument name="at_call" xsi:type="string">getBrand</argument>
        <argument name="at_code" xsi:type="string">brand</argument>
        <argument name="css_class" xsi:type="string">brand</argument>
        <argument name="at_label" xsi:type="string">default</argument>
        <argument name="add_attribute" xsi:type="string">itemprop="brand"</argument>
      </arguments>
      </block>

 

Step 2: move it to your location

<move element="page.main.brand" destination="product.info.main" after="page.main.title"/>

Step 3 : udpate phtml file with your custom html and code

<?php
/**
 * Copyright © 2016 Magento. All rights reserved.
 * See COPYING.txt for license details.
 */

// @codingStandardsIgnoreFile

/**
 * Product description template
 *
 * @var $block \Magento\Catalog\Block\Product\View\Description
 */
?>
<?php
$_helper = $this->helper('Magento\Catalog\Helper\Output');
$_product = $block->getProduct();
 
$_code = $block->getAtCode();
$_className = $block->getCssClass();
$_attributeLabel = $block->getAtLabel();
$_attributeType = $block->getAtType();
$_attributeAddAttribute = $block->getAddAttribute();
 
if ($_attributeLabel && $_attributeLabel == 'default') {
$_attributeLabel = $_product->getResource()->getAttribute($_code)->getFrontendLabel();
}
 
$_attributeValue =$_product->getResource()->getAttribute($_code)->getFrontend()->getValue($_product);
 
?>
 
<?php if ($_attributeValue): ?>
<div class="product attibute <?php echo $_className?>">
<?php /*?><?php if ($_attributeLabel != 'none'): ?><strong class="type"><?php echo $_attributeLabel?></strong><?php endif; ?><?php */?>
<div class="value" <?php echo $_attributeAddAttribute;?>><?php echo $_attributeValue; ?></div>
</div>
<?php endif; ?>