I have created recently viewed widget, and added this in product view page, but the product view I want is to be like as it is displaying on prodcut listing page/category product listing page. how could I achieve this?
3
-
Can you show us what you have done so far? – jscar Jul 5 '17 at 8:07
-
The problem has been solved, as i used report/product_veiwed.phtml file in my theme folder from base, and i strucured that file as product view page. Is this right solution? – onlyfordigitalworld Jul 5 '17 at 8:42
-
That sounds right :). Could you post an answer here and mark it as correct so others can benefit from your experience? – jscar Jul 5 '17 at 9:11
Add a comment
|
If you want to display the viewed product in the content of product page you can do it properly in xml like this:
app/design/frontend/{package}/{theme}/layout/local.xml
<catalog_product_view>
<reference name="root">
<block type="block/type" name="name.block" template="path to template.phtml"/> <!-- the recently viewed block -->
</reference>
</catalog_product_view>
Then go app/design/frontend/{package}/{theme}/template/catalog/product/view.phtml
then put this where you want to display theme:
<?php echo this->getBlockHtml('name.block'); ?>
<?php if ($_products = $this->getRecentlyViewedProducts()): ?>
<div class="container container--wide recently-viewed-section">
<div class="block block-list block-viewed">
<div class="group-header">
<div class="group-heading">
<?php echo $this->__('Recently Viewed Items') ?></span></strong>
</div>
</div>
<div class="block-content">
<ol class="product-grid" id="recently-viewed-items">
<?php foreach ($_products as $product): ?>
<li class="product-grid_item product-tile">
<a class="product-image" href="<?php echo $product->getProductUrl(); ?>">
<div class="quickview"><button class="button button--s button--inverted">Quick View</button></div>
<picture class="pimg1">
<source srcset="<?php echo $this->helper('catalog/image')->init($product, 'small_image')->resize(290, 290); ?>" media="(min-width: 400px)">
<img srcset="<?php echo $this->helper('catalog/image')->init($product, 'small_image')->resize(130, 130); ?>" alt="<?php echo $this->escapeHtml($this->getImageLabel($product, 'small_image')); ?>">
</picture>
<picture class="pimg2">
<source srcset="<?php echo $this->helper('catalog/image')->init($product, 'thumbnail')->resize(290, 290); ?>" media="(min-width: 400px)">
<img srcset="<?php echo $this->helper('catalog/image')->init($product, 'thumbnail')->resize(130, 130); ?>" alt="<?php echo $this->escapeHtml($this->getImageLabel($product, 'thumbnail')); ?>">
</picture>
<?php
$isNewProduct = Mage::helper('magefrontend')->isNewProduct($product);
?>
<?php if ($isNewProduct): ?>
<ul class="badge-list">
<li class="badge-list_item badge-list_item--new">
<?php echo $this->__('New'); ?>
</li>
</ul>
<?php endif; ?>
</a>
<?php
$showMessage = false;
$tmpProduct = $product->load($product->getId());
foreach ($tmpProduct->getOptions() as $productSize) {
if($productSize->getTitle() == 'Size'){ // Use Your Size Option Title
$values = $productSize->getValues();
foreach ($values as $value){
if($value->getTitle() == 'XL'){ // Use your option text to match
$showMessage = true;
break;
}
}
}
}
?>
<?php if($showMessage): ?>
<div class="product-banner-box">
<span class="plussize-banner">now in plus sizes</span>
</div>
<?php endif; ?>
<!-- <div class="product-banner-box">
<span class="plussize-banner">now in plus sizes</span>
</div> -->
<?php if ($product->getRatingSummary()): ?>
<?php echo $this->getReviewsSummaryHtml($product, 'short'); ?>
<?php endif; ?>
<?php echo $this->getPriceHtml($product, true); ?>
<?php if ($this->helper('wishlist')->isAllow()): ?>
<a class="product-addwishlist" href="<?php echo $this->helper('wishlist')->getAddUrl($product); ?>">
<span class="trigger-icon icon-heart"></span>
</a>
<?php endif; ?>
<a class="product-name" href="<?php echo $product->getProductUrl(); ?>">
<?php
echo Mage::helper('magefrontend')->preventTypographicWidow(
$this->escapeHtml($product->getName())
);
?>
</a>
<?php if ($product->isSaleable()): ?>
<?php else: ?>
<div class="availability">
<span class="out-of-stock"><?php echo $this->__('Out Of Stock'); ?></span>
</div>
<?php endif; ?>
</li>
<?php endforeach; ?>
<li class="product-grid_item flex-ghost"></li>
<li class="product-grid_item flex-ghost"></li>
<li class="product-grid_item flex-ghost"></li>
<li class="product-grid_item flex-ghost"></li>
</ol>
<script type="text/javascript">decorateList('recently-viewed-items');</script>
</div>