I'm trying to get a product attribute on the product listing page, on title.phtml
.
I've tried quite a few different methods found through googling but nothing seems to be working.
<?php
/**
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
// @codingStandardsIgnoreFile
/**
* @var $block \Magento\Theme\Block\Html\Title
*/
$cssClass = $block->getCssClass() ? ' ' . $block->getCssClass() : '';
$title = '';
if (trim($block->getPageHeading())) {
$title = '<span class="base" data-ui-id="page-title-wrapper" ' . $block->getAddBaseAttribute() . '>'
. $block->escapeHtml($block->getPageHeading()) . '</span>';
}
?>
<?php if ($title): ?>
<div class="page-title-wrapper<?php /* @escapeNotVerified */
echo $cssClass; ?>">
<h1 class="page-title"
<?php if ($block->getId()): ?> id="<?php /* @escapeNotVerified */
echo $block->getId(); ?>" <?php endif; ?>
<?php if ($block->getAddBaseAttributeAria()): ?>
aria-labelledby="<?php /* @escapeNotVerified */
echo $block->getAddBaseAttributeAria(); ?>"
<?php endif; ?>>
<?php /* @escapeNotVerified */
echo $title ?>
</h1>
testing:
<?php
$attr = $block->getData('style_general');
echo $attr;
?>
<?php echo $block->getStyle_general(); ?>
<?php echo $block->getChildHtml(); ?>
</div>
<?php endif; ?>
Testing:
$attr = $block->getData('style_general');
echo $attr;
is the current method I'm trying, but it nothing is showing up...
vendor\magento\module-catalog\view\frontend\templates\product\list.phtml
?. I don't know why you want to get custom attribute invendor\magento\module-theme\view\frontend\templates\html\title.phtml