Category Archives: Magento 2

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() ?>" />