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
);