Skip to content

simplify product lists #2 #9019

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 18, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,10 @@ $_helper = $this->helper('Magento\Catalog\Helper\Output');
$pos = $block->getPositioned();
?>
<div class="products wrapper <?= /* @escapeNotVerified */ $viewMode ?> products-<?= /* @escapeNotVerified */ $viewMode ?>">
<?php $iterator = 1; ?>
<ol class="products list items product-items">
<?php /** @var $_product \Magento\Catalog\Model\Product */ ?>
<?php foreach ($_productCollection as $_product): ?>
<?= /* @escapeNotVerified */ ($iterator++ == 1) ? '<li class="item product product-item">' : '</li><li class="item product product-item">' ?>
<li class="item product product-item">
<div class="product-item-info" data-container="product-grid">
<?php
$productImage = $block->getImage($_product, $image);
Expand Down Expand Up @@ -112,7 +111,7 @@ $_helper = $this->helper('Magento\Catalog\Helper\Output');
</div>
</div>
</div>
<?= ($iterator == count($_productCollection)+1) ? '</li>' : '' ?>
</li>
<?php endforeach; ?>
</ol>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@ switch ($type = $block->getType()) {
<?php endif; ?>
<div class="products wrapper grid products-grid products-<?= /* @escapeNotVerified */ $type ?>">
<ol class="products list items product-items">
<?php $iterator = 1; ?>
<?php foreach ($items as $_item): ?>
<?php $available = ''; ?>
<?php if (!$_item->isComposite() && $_item->isSaleable() && $type == 'related'): ?>
Expand All @@ -183,9 +182,9 @@ switch ($type = $block->getType()) {
<?php endif; ?>
<?php endif; ?>
<?php if ($type == 'related' || $type == 'upsell'): ?>
<?= /* @escapeNotVerified */ ($iterator++ == 1) ? '<li class="item product product-item" style="display: none;">' : '</li><li class="item product product-item" style="display: none;">' ?>
<li class="item product product-item" style="display: none;">
<?php else: ?>
<?= /* @escapeNotVerified */ ($iterator++ == 1) ? '<li class="item product product-item">' : '</li><li class="item product product-item">' ?>
<li class="item product product-item">
<?php endif; ?>
<div class="product-item-info <?= /* @escapeNotVerified */ $available ?>">
<?= /* @escapeNotVerified */ '<!-- ' . $image . '-->' ?>
Expand Down Expand Up @@ -252,7 +251,7 @@ switch ($type = $block->getType()) {
<?php endif; ?>
</div>
</div>
<?= ($iterator == count($items)+1) ? '</li>' : '' ?>
</li>
<?php endforeach ?>
</ol>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,61 +38,60 @@ $_helper = $this->helper('Magento\Catalog\Helper\Output');
}
?>
<div class="products wrapper <?= /* @escapeNotVerified */ $viewMode ?>">
<?php $iterator = 1; ?>
<ol class="products list items">
<?php foreach ($_productCollection as $_product): ?>
<?= /* @escapeNotVerified */ ($iterator++ == 1) ? '<li class="item product">' : '</li><li class="item product">' ?>
<div class="product">
<?php // Product Image ?>
<a href="<?= /* @escapeNotVerified */ $_product->getProductUrl() ?>" class="product photo">
<?= $block->getImage($_product, $image)->toHtml() ?>
</a>
<div class="product details">
<?php
<li class="item product">
<div class="product">
<?php // Product Image ?>
<a href="<?= /* @escapeNotVerified */ $_product->getProductUrl() ?>" class="product photo">
<?= $block->getImage($_product, $image)->toHtml() ?>
</a>
<div class="product details">
<?php

$info = [];
$info['name'] = '<strong class="product name">'
. ' <a href="' . $_product->getProductUrl() . '" title="'
. $block->stripTags($_product->getName(), null, true) . '">'
. $_helper->productAttribute($_product, $_product->getName(), 'name')
. '</a></strong>';
$info['price'] = $block->getProductPrice($_product);
$info['review'] = $block->getReviewsSummaryHtml($_product, $templateType);
$info = [];
$info['name'] = '<strong class="product name">'
. ' <a href="' . $_product->getProductUrl() . '" title="'
. $block->stripTags($_product->getName(), null, true) . '">'
. $_helper->productAttribute($_product, $_product->getName(), 'name')
. '</a></strong>';
$info['price'] = $block->getProductPrice($_product);
$info['review'] = $block->getReviewsSummaryHtml($_product, $templateType);

if ($_product->isSaleable()) {
$info['button'] = '<button type="button" title="' . __('Add to Cart') . '" class="action tocart"'
. ' data-mage-init=\'{ "redirectUrl": { "event": "click", url: "' . $block->getAddToCartUrl($_product) . '"} }\'>'
. '<span>' . __('Add to Cart') . '</span></button>';
} else {
$info['button'] = $_product->getIsSalable() ? '<div class="stock available"><span>' . __('In stock') . '</span></div>' :
'<div class="stock unavailable"><span>' . __('Out of stock') . '</span></div>';
}
if ($_product->isSaleable()) {
$info['button'] = '<button type="button" title="' . __('Add to Cart') . '" class="action tocart"'
. ' data-mage-init=\'{ "redirectUrl": { "event": "click", url: "' . $block->getAddToCartUrl($_product) . '"} }\'>'
. '<span>' . __('Add to Cart') . '</span></button>';
} else {
$info['button'] = $_product->getIsSalable() ? '<div class="stock available"><span>' . __('In stock') . '</span></div>' :
'<div class="stock unavailable"><span>' . __('Out of stock') . '</span></div>';
}

$info['links'] = '<div class="product links" data-role="add-to-links">'
. '<a href="#" data-post=\'' . $this->helper('Magento\Wishlist\Helper\Data')->getAddParams($_product) . '\' class="action towishlist" data-action="add-to-wishlist">'
. '<span>' . __('Add to Wish List') . '</span></a>'
. '<a href="' . $block->getAddToCompareUrl($_product) . '" class="action tocompare">'
. '<span>' . __('Add to Compare') . '</span></a></div>';
$info['actions'] = '<div class="product action">' . $info['button'] . $info['links'] . '</div>';
$info['links'] = '<div class="product links" data-role="add-to-links">'
. '<a href="#" data-post=\'' . $this->helper('Magento\Wishlist\Helper\Data')->getAddParams($_product) . '\' class="action towishlist" data-action="add-to-wishlist">'
. '<span>' . __('Add to Wish List') . '</span></a>'
. '<a href="' . $block->getAddToCompareUrl($_product) . '" class="action tocompare">'
. '<span>' . __('Add to Compare') . '</span></a></div>';
$info['actions'] = '<div class="product action">' . $info['button'] . $info['links'] . '</div>';

if ($showDescription) {
$info['description'] = '<div class="product description">'
. $_helper->productAttribute($_product, $_product->getShortDescription(), 'short_description')
. ' <a href="' . $_product->getProductUrl() . '" class="action more">'
. __('Learn More') . '</a></div>';
} else {
$info['description'] = '';
}
if ($showDescription) {
$info['description'] = '<div class="product description">'
. $_helper->productAttribute($_product, $_product->getShortDescription(), 'short_description')
. ' <a href="' . $_product->getProductUrl() . '" class="action more">'
. __('Learn More') . '</a></div>';
} else {
$info['description'] = '';
}

$details = $block->getInfoOrder() ?: ['name','price','review','description','actions'];
foreach ($details as $detail) {
/* @escapeNotVerified */ echo $info[$detail];
}
?>
$details = $block->getInfoOrder() ?: ['name','price','review','description','actions'];
foreach ($details as $detail) {
/* @escapeNotVerified */ echo $info[$detail];
}
?>

</div>
</div>
</div>
<?= ($iterator == count($_productCollection)+1) ? '</li>' : '' ?>
</li>
<?php endforeach; ?>
</ol>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,59 +14,58 @@
</div>
<div class="block-content">
<?php $suffix = $block->getNameInLayout(); ?>
<?php $iterator = 1; ?>
<ol class="product-items" id="widget-new-products-<?= /* @escapeNotVerified */ $suffix ?>">
<?php foreach ($_products->getItems() as $_product): ?>
<?= /* @escapeNotVerified */ ($iterator++ == 1) ? '<li class="product-item">' : '</li><li class="product-item">' ?>
<div class="product-item-info">
<a class="product-item-photo" href="<?= /* @escapeNotVerified */ $_product->getProductUrl() ?>"
title="<?= /* @escapeNotVerified */ $block->stripTags($_product->getName(), null, true) ?>">
<?= $block->getImage($_product, 'side_column_widget_product_thumbnail')->toHtml() ?>
</a>
<div class="product-item-details">
<strong class="product-item-name">
<a href="<?= /* @escapeNotVerified */ $_product->getProductUrl() ?>"
title="<?= /* @escapeNotVerified */ $block->stripTags($_product->getName(), null, true) ?>)" class="product-item-link">
<?= /* @escapeNotVerified */ $this->helper('Magento\Catalog\Helper\Output')->productAttribute($_product, $_product->getName(), 'name') ?>
</a>
</strong>
<?= /* @escapeNotVerified */ $block->getProductPriceHtml($_product, '-widget-new-' . $suffix) ?>
<div class="product-item-actions">
<div class="actions-primary">
<?php if ($_product->isSaleable()): ?>
<?php if ($_product->getTypeInstance()->hasRequiredOptions($_product)): ?>
<button type="button" title="<?= /* @escapeNotVerified */ __('Add to Cart') ?>"
class="action tocart primary"
data-mage-init='{"redirectUrl":{"url":"<?= /* @escapeNotVerified */ $block->getAddToCartUrl($_product) ?>"}}'>
<span><?= /* @escapeNotVerified */ __('Add to Cart') ?></span>
</button>
<li class="product-item">
<div class="product-item-info">
<a class="product-item-photo" href="<?= /* @escapeNotVerified */ $_product->getProductUrl() ?>"
title="<?= /* @escapeNotVerified */ $block->stripTags($_product->getName(), null, true) ?>">
<?= $block->getImage($_product, 'side_column_widget_product_thumbnail')->toHtml() ?>
</a>
<div class="product-item-details">
<strong class="product-item-name">
<a href="<?= /* @escapeNotVerified */ $_product->getProductUrl() ?>"
title="<?= /* @escapeNotVerified */ $block->stripTags($_product->getName(), null, true) ?>)" class="product-item-link">
<?= /* @escapeNotVerified */ $this->helper('Magento\Catalog\Helper\Output')->productAttribute($_product, $_product->getName(), 'name') ?>
</a>
</strong>
<?= /* @escapeNotVerified */ $block->getProductPriceHtml($_product, '-widget-new-' . $suffix) ?>
<div class="product-item-actions">
<div class="actions-primary">
<?php if ($_product->isSaleable()): ?>
<?php if ($_product->getTypeInstance()->hasRequiredOptions($_product)): ?>
<button type="button" title="<?= /* @escapeNotVerified */ __('Add to Cart') ?>"
class="action tocart primary"
data-mage-init='{"redirectUrl":{"url":"<?= /* @escapeNotVerified */ $block->getAddToCartUrl($_product) ?>"}}'>
<span><?= /* @escapeNotVerified */ __('Add to Cart') ?></span>
</button>
<?php else: ?>
<?php
$postDataHelper = $this->helper('Magento\Framework\Data\Helper\PostHelper');
$postData = $postDataHelper->getPostData($block->getAddToCartUrl($_product), ['product' => $_product->getEntityId()]);
?>
<button type="button" title="<?= /* @escapeNotVerified */ __('Add to Cart') ?>"
class="action tocart primary"
data-post='<?= /* @escapeNotVerified */ $postData ?>'>
<span><?= /* @escapeNotVerified */ __('Add to Cart') ?></span>
</button>
<?php endif; ?>
<?php else: ?>
<?php
$postDataHelper = $this->helper('Magento\Framework\Data\Helper\PostHelper');
$postData = $postDataHelper->getPostData($block->getAddToCartUrl($_product), ['product' => $_product->getEntityId()]);
?>
<button type="button" title="<?= /* @escapeNotVerified */ __('Add to Cart') ?>"
class="action tocart primary"
data-post='<?= /* @escapeNotVerified */ $postData ?>'>
<span><?= /* @escapeNotVerified */ __('Add to Cart') ?></span>
</button>
<?php if ($_product->getIsSalable()): ?>
<div class="stock available" title="<?= /* @escapeNotVerified */ __('Availability') ?>">
<span><?= /* @escapeNotVerified */ __('In stock') ?></span>
</div>
<?php else: ?>
<div class="stock unavailable" title="<?= /* @escapeNotVerified */ __('Availability') ?>">
<span><?= /* @escapeNotVerified */ __('Out of stock') ?></span>
</div>
<?php endif; ?>
<?php endif; ?>
<?php else: ?>
<?php if ($_product->getIsSalable()): ?>
<div class="stock available" title="<?= /* @escapeNotVerified */ __('Availability') ?>">
<span><?= /* @escapeNotVerified */ __('In stock') ?></span>
</div>
<?php else: ?>
<div class="stock unavailable" title="<?= /* @escapeNotVerified */ __('Availability') ?>">
<span><?= /* @escapeNotVerified */ __('Out of stock') ?></span>
</div>
<?php endif; ?>
<?php endif; ?>
</div>
</div>
</div>
</div>
</div>
<?= ($iterator == count($_products->getItems())+1) ? '</li>' : '' ?>
</li>
<?php endforeach; ?>
</ol>
<?= $block->getPagerHtml() ?>
Expand Down
Loading