Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
attribute.phtml
Go to the documentation of this file.
1 <?php
7 // @codingStandardsIgnoreFile
8 
14 ?>
15 <?php
16 $_helper = $this->helper('Magento\Catalog\Helper\Output');
17 $_product = $block->getProduct();
18 $_call = $block->getAtCall();
19 $_code = $block->getAtCode();
20 $_className = $block->getCssClass();
21 $_attributeLabel = $block->getAtLabel();
22 $_attributeType = $block->getAtType();
23 $_attributeAddAttribute = $block->getAddAttribute();
24 
25 $renderLabel = true;
26 // if defined as 'none' in layout, do not render
27 if ($_attributeLabel == 'none') {
28  $renderLabel = false;
29 }
30 
31 if ($_attributeLabel && $_attributeLabel == 'default') {
32  $_attributeLabel = $_product->getResource()->getAttribute($_code)->getStoreLabel();
33 }
34 if ($_attributeType && $_attributeType == 'text') {
35  $_attributeValue = ($_helper->productAttribute($_product, $_product->$_call(), $_code)) ? $_product->getAttributeText($_code) : '';
36 } else {
37  $_attributeValue = $_helper->productAttribute($_product, $_product->$_call(), $_code);
38 }
39 ?>
40 
41 <?php if ($_attributeValue): ?>
42 <div class="product attribute <?= /* @escapeNotVerified */ $_className ?>">
43  <?php if ($renderLabel): ?><strong class="type"><?= /* @escapeNotVerified */ $_attributeLabel ?></strong><?php endif; ?>
44  <div class="value" <?= /* @escapeNotVerified */ $_attributeAddAttribute ?>><?= /* @escapeNotVerified */ $_attributeValue ?></div>
45 </div>
46 <?php endif; ?>
if( $_attributeValue)($renderLabel) endif
Definition: attribute.phtml:44
$_product
Definition: attribute.phtml:17
$_code
Definition: attribute.phtml:19
$block
Definition: block.php:8
$_className
Definition: attribute.phtml:20
$_attributeType
Definition: attribute.phtml:22
$_call
Definition: attribute.phtml:18
$renderLabel
Definition: attribute.phtml:25
$_attributeAddAttribute
Definition: attribute.phtml:23
$_helper
Definition: attribute.phtml:16
$_attributeLabel
Definition: attribute.phtml:21