Custom attribute Magento 2 - magento2

I'm trying to override a magento module for displaying a customer attribute 'eco_taxe', I can get it but I return error when I try to go to my homepage.
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ ?>
<?php /* #var $block \Magento\Framework\Pricing\Render\Amount / ?> <?php $blockObj= $block->getLayout()->createBlock('\Magento\Catalog\Block\Product\View\Attributes'); ?> <?php $_additional = $blockObj->getAdditionalData(); ?>
<span class="price-container <?= $block->escapeHtmlAttr($block->getAdjustmentCssClasses()) ?>"
<?= $block->getSchema() ? ' itemprop="offers" itemscope itemtype="http://schema.org/Offer"' : '' ?>>
<?php if ($block->getDisplayLabel()) :?>
<span class="price-label"><?= $block->escapeHtml($block->getDisplayLabel()) ?></span>
<?php endif; ?>
<span <?php if ($block->getPriceId()) :?> id="<?= $block->escapeHtmlAttr($block->getPriceId()) ?>"<?php endif;?>
<?= ($block->getPriceDisplayLabel()) ? 'data-label="' . $block->escapeHtmlAttr($block->getPriceDisplayLabel() . $block->getPriceDisplayInclExclTaxes()) . '"' : '' ?>
data-price-amount="<?= $block->escapeHtmlAttr($block->getDisplayValue()) ?>"
data-price-type="<?= $block->escapeHtmlAttr($block->getPriceType()) ?>"
class="price-wrapper <?= $block->escapeHtmlAttr($block->getPriceWrapperCss()) ?>"
><?= $block->escapeHtml($block->formatCurrency($block->getDisplayValue(), (bool)$block->getIncludeContainer()), ['span']) ?> </span> prix public HT
<span><?= $_additional["eco_taxe"]["value"]; ?> € d'écotaxe </span>
<?php if ($block->hasAdjustmentsHtml()) :?>
<?= $block->getAdjustmentsHtml() ?>
<?php endif; ?>
<?php if ($block->getSchema()) :?>
<meta itemprop="price" content="<?= $block->escapeHtmlAttr($block->getDisplayValue()) ?>" />
<meta itemprop="priceCurrency" content="<?= $block->escapeHtmlAttr($block->getDisplayCurrencyCode()) ?>" />
<?php endif; ?> </span>
How can I get the custom attribute 'eco_taxe' ?
<span><?= $_additional["eco_taxe"]["value"]; ?> € d'écotaxe </span>
<?php $blockObj= $block->getLayout()->createBlock('\Magento\Catalog\Block\Product\View\Attributes'); ?>
<?php $_additional = $blockObj->getAdditionalData(); ?>

Related

undefinied variable when load view | codeigniter 3

For example this working code:
home view:
<div class="slider variable-width">
<?php $this->load->view('product/_product_item_slider'); ?>
</div>
and in product/_product_item_slider
<?php foreach ($this->product_model->get_products_by_category_id(1) as $product): ?>
<?php echo get_product_item_image($product); ?>
<?php endforeach ?>
but when I do in this way:
home view:
<div class="slider variable-width">
<?php foreach ($this->product_model->get_products_by_category_id(1) as $product): ?>
<?php $this->load->view('product/_product_item_slider'); ?>
<?php endforeach ?>`
</div>
and in product/_product_item_slider
<?php echo get_product_item_image($product); ?>
I get:
Message: Undefined variable: product

Bad formatting in PhpStorm but much better formatting in Visual Studio Code. How to setup PhpStorm for better/same formatting?

I think I wrote everything in the headline. Here are two examples:
PhpStorm
Visual Studio Code
It seems that Visual Studio does his job much better but I'm completely into PhpStorm so I cant switch because of that right now. Do you have any ideas on how can I match the Code Format?
Here is the code-snippet
<div <?php echo $this->cssID; ?> class="content--element <?php echo $this->class; ?>">
<div class="ce--inner container">
<?php if ($this->headline || $this->subline) : ?>
<div class="ce--headline"
data-aos="<?php if ($this->animation_type) : ?><?php echo $this->animation_type; ?><?php else : ?>animate__fadeInUp<?php endif; ?>">
<?php if ($this->headline) : ?>
<<?php echo($this->hl); ?>>
<?php echo($this->headline); ?>
</<?php echo($this->hl); ?>>
<?php endif; ?>
<?php if ($this->subline) : ?>
<span class="ce--subline"><?php echo $this->subline; ?></span>
<?php endif; ?>
</div>
<?php endif; ?>
<?php if ($this->boxes) : ?>
<div class="row">
<?php foreach ($this->boxes as $box) : ?>
<div class="<?php if ($box->column_width) : ?><?php echo $box->column_width; ?><?php else : ?>col-12 col-md-6 col-lg-4<?php endif; ?>">
<div class="advantages--box"
data-aos="<?php if ($box->animation_type) : ?><?php echo $box->animation_type; ?><?php else : ?>animate__fadeInUp<?php endif; ?>">
<?php if ($box->ce_headline) : ?>
<div class="advantages--headline">
<?php if (!$box->onlystyle) : ?>
<<?php echo $box->headline_type; ?>>
<?php echo $box->ce_headline; ?>
</<?php echo $box->headline_type; ?>>
<?php if ($box->ce_subline) : ?>
<span class="ce--subline advantages--subline">
<?php echo $box->ce_subline; ?>
</span>
<?php endif; ?>
<?php else : ?>
<span class="<?php echo $box->headline_type; ?>">
<?php echo $box->ce_headline; ?>
</span>
<?php if ($box->ce_subline) : ?>
<span class="ce--subline advantages--subline">
<?php echo $box->ce_subline; ?>
</span>
<?php endif; ?>
<?php endif; ?>
</div>
<?php endif; ?>
<?php if ($box->text) : ?>
<div class="advantages--text">
<?php echo $box->text; ?>
</div>
<?php endif; ?>
</div>
</div>
<?php endforeach ?>
</div>
<?php endif; ?>
</div>
</div>

sending request to users in the same model

i want to send a request to a user to join community, so firstly i want to check if the username is exists in the database..then send request data, so how i can do it? here is the code :
<?php echo CHtml::beginForm('','post',array('enctype'=>'multipart/form-data')); ?>
<div class="form">
<?php $form=$this->beginWidget('CActiveForm', array(
'id'=>'users-form',
'enableAjaxValidation'=>true,
)); ?>
<p class="note">Fields with <span class="required">*</span> are required.</p>
<?php echo $form->errorSummary($model); ?>
<div class="row">
<?php echo $form->labelEx($model,'userName'); ?>
<?php echo CHtml::textField('userName','',array('size'=>45,'maxlength'=>255, 'id'=>'in')); ?>
<?php echo $form->error($model,'userName'); ?>
</div>
<div class="row buttons">
<?php $urlDe=CHtml::normalizeUrl(array("users/communities/".$model->idUser)); ?>
<?php echo CHtml::submitButton('Send',array('submit' => $urlDe, 'id'=>'but')); ?>
<?php //echo CHtml::submitButton($model->isNewRecord ? 'Create' :'Send', array('id'=>'but')); ?>
<?php echo CHtml::resetButton('Reset', array('id'=>'but')); ?>
</div>
<?php $this->endWidget(); ?>
</div><!-- form -->
<?php echo CHtml::endForm(); ?>
this is the invite action..how i can send the invite data to an action belong to the user?
the community and user are in the same model.

Products still showing when set to Not Visible Individually

Using Magmi to upload a CSV to set simple products to be Not Visible Individually.
After clearing Magento Cache and Reindexing, the products still show on the category page however clicking on the simple products give you a 404 page.
Is there anyway to stop these products showing on the category page.
Example of were this happens http://boxchilli.co/s2as/kayaks-1.html
PROTEC ACE WATER HELMET - WHITE at the top isn't ment to show but the PROTEC ACE WATER HELMET - WHITE2 is
Code for list.phtml added below
<?php
$_productCollection=$this->getLoadedProductCollection();
$_helper = $this->helper('catalog/output');
?>
<?php if(!$_productCollection->count()): ?>
<p class="note-msg"><?php echo $this->__('There are no products matching the selection.') ?></p>
<!--<script type="text/javascript">
jQuery(window).load(function() {
jQuery('.page').css('background-image','none');
});
</script>-->
<?php else: ?>
<div class="category-products">
<?php $position = 'top'; ?>
<?php echo $this->getToolbarHtml($position) ?>
<?php // List mode ?>
<?php if($this->getMode()!='grid'): ?>
<?php $_iterator = 0; ?>
<ol class="products-list" id="products-list">
<?php foreach ($_productCollection as $_product): ?>
<li class="item<?php if( ++$_iterator == sizeof($_productCollection) ): ?> last<?php endif; ?>">
<?php // Product Image ?>
<img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(130); ?>" width="130" height="130" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" />
<?php // Product description ?>
<div class="product-shop">
<div class="f-fix">
<?php $_productNameStripped = $this->stripTags($_product->getName(), null, true); ?>
<h2 class="product-name"><?php echo $_helper->productAttribute($_product, $_product->getName() , 'name'); ?></h2>
<?php if($_product->getRatingSummary()): ?>
<?php echo $this->getReviewsSummaryHtml($_product) ?>
<?php endif; ?>
<?php echo $this->getPriceHtml($_product, true) ?>
<?php if($_product->isSaleable()): ?>
<p><button type="button" title="<?php echo $this->__('BUY NOW') ?>" class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><span><span><?php echo $this->__('BUY NOW') ?></span></span></button></p>
<?php else: ?>
<p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
<?php endif; ?>
<div class="desc std">
<?php $shortened = truncateText($_product['description'],250,'.'); ?>
<?php
$product_data = $_product->getData();
if($_product->getName() == 'Mystic Warrior III (3) Kitesurf Waist Harness 2012 - Black'){print_r($product_data);}
?>
<?php print_r($_product['description']); ?>
<?php echo $this->__('Learn More') ?>
</div>
<ul class="add-to-links">
<?php if ($this->helper('wishlist')->isAllow()) : ?>
<li><?php echo $this->__('Add to Wishlist') ?></li>
<?php endif; ?>
</ul>
</div>
</div>
</li>
<?php endforeach; ?>
</ol>
<script type="text/javascript">decorateList('products-list', 'none-recursive')</script>
<?php else: ?>
<?php // Grid Mode ?>
<?php $_collectionSize = $_productCollection->count() ?>
<?php $_columnCount = $this->getColumnCount(); ?>
<?php $_columnCount = 4; ?>
<?php $i=0; foreach ($_productCollection as $_product): ?>
<?php if ($i++%$_columnCount==0): ?>
<ul class="products-grid">
<?php endif ?>
<li class="item<?php if(($i-1)%$_columnCount==0): ?> first<?php elseif($i%$_columnCount==0): ?> last<?php endif; ?>">
<img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(158); ?>" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" />
<?php $shortened = truncateText($_product->getName(),250,'.'); ?>
<h2 class="product-name"><?php echo $_helper->productAttribute($_product, $_product->getName(), 'name') ?></h2>
<?php if($_product->getRatingSummary()): ?>
<?php echo $this->getReviewsSummaryHtml($_product, 'short') ?>
<?php endif; ?>
<?php echo $this->getPriceHtml($_product, true) ?>
<div class="actions">
<?php if($_product->isSaleable()): ?>
<button type="button" title="<?php echo $this->__('BUY NOW') ?>" class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><span><span><?php echo $this->__('BUY NOW') ?></span></span></button>
<?php else: ?>
<p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
<?php endif; ?>
<ul class="add-to-links">
<?php if ($this->helper('wishlist')->isAllow()) : ?>
<li><?php echo $this->__('Add to Wishlist') ?></li>
<?php endif; ?>
</ul>
</div>
</li>
<?php if ($i%$_columnCount==0 || $i==$_collectionSize): ?>
</ul>
<?php endif ?>
<?php endforeach ?>
<script type="text/javascript">decorateGeneric($$('ul.products-grid'), ['odd','even','first','last'])</script>
<?php endif; ?>
<?php $position = 'bottom'; ?>
<div class="toolbar-bottom">
<?php echo $this->getToolbarBlock()->setTemplate('catalog/product/list/toolbar_bottom.phtml')->toHtml(); ?>
</div>
</div>
<?php endif; ?>
Resolved the issue.
Indexing was erroring without reporting back and nothing on the error log. By doing each reindex one by one it resolved the problem.
Make sure the products aren't assigned to a category too. I had the same issue with an inherited site.

Magento, Showing Star Ratings in Custom Template

I've managed to show the prices for each product, but I can not show the star ratings for each product, this is a separate template file, I'm referencing the original list.phtml but something isn't right, I can only assume I'm missing something:
<div class="category-products">
<div class="products-grid">
<?php
$_helper = Mage::helper('catalog/output');
$categoryid = 26;
$category = Mage::getModel('catalog/category');
$category->load($categoryid);
$collection = $category->getProductCollection();
$collection->addAttributeToSelect('*');
foreach ($collection as $_product) {
?>
<div class="item">
<img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(135); ?>" width="135" height="135" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" />
<h2 class="product-name"><?php echo $_product->getName(); ?></h2>
<?php if($_product->getRatingSummary()): ?>
<?php echo $this->getReviewsSummaryHtml($_product, 'short') ?>
<?php endif; ?>
<?php
$product_block = new Mage_Catalog_Block_Product;
echo $product_block->getPriceHtml($_product);
?>
<div class="actions">
<?php if($_product->isSaleable()): ?>
<button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button>
<?php else: ?>
<p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
<?php endif; ?>
</div>
</div>
<?php } ?>
</div>
The getReviewsSummaryHtml() is not showing the stars...