J'essaie de créer mes pages de destination pour mes produits sur mon site Web, mais je souhaite qu'il affiche des produits aléatoires en haut de la page (dans la zone de description). J'ai tout le code pour obtenir les produits aléatoires dans random.phtml et il fonctionne parce que je l'ai testé sur une page CMS « Test » avec le code:Comment afficher des produits aléatoires dans la "description" des catégories
{{block type="midmedssettings/product_list" num_products="5" category_id="145" template="catalog/product/random.phtml"}}
Cependant quand je mets cela dans la zone Description en Dans ma catégorie, il ne reconnaît pas le code et affiche uniquement le code. J'ai essayé
<block type="midmedssettings/product_list" num_products="5" category_id="145" template="catalog/product/random.phtml">
mais cela n'affichait rien.
random.phtml
<?php
/**
* Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @category design_default
* @package Mage
* @copyright Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
?>
<?php
/**
* Product list template
*
* @see Mage_Catalog_Block_Product_List
*/
?>
<?php
Mage::getSingleton('catalog/layer')->setData("product_collection",NULL);
$this->_productCollection = null;
$_productCollection=$this->getLoadedProductCollection();
?>
<?php $_productCollection=$this->getLoadedProductCollection() ?>
<?php if(!$_productCollection->count()): ?>
<div class="padder">
<div class="note-msg">
<?php echo $this->__('There are no products matching the selection.') ?>
</div>
</div>
<?php else: ?>
<?php // Grid Mode ?>
<div class="listing-type-grid catalog-listing padder"> <!-- the class name will change to .listing-type-cell if viewing in list mode -->
<?php $_collectionSize = $_productCollection->count() ?>
<?php $_items = $_productCollection->getItems();
shuffle($_items); ?>
<table cellspacing="0" class="generic-product-grid" id="product-list-table">
<?php $i=0; foreach ($_items as $_product): ?>
<?php if ($i++%4==0): ?>
<tr>
<?php endif ?>
<td>
<p class="product-image">
<a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>">
<img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(170, 170); ?>" alt="<?php echo $this->htmlEscape($_product->getName()) ?>"/>
</a>
</p>
<h5><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>"><?php echo $this->htmlEscape($_product->getName()) ?></a></h5>
<?php if($_product->getRatingSummary()): ?>
<!--?php echo $this->getReviewsSummaryHtml($_product, 'short') ?-->
<?php echo $this->getReviewsSummaryHtml($_product) ?>
<?php endif; ?>
<?php echo $this->getPriceHtml($_product, true) ?>
<div class="clear"></div>
<ul class="add-to">
<?php if($_product->isSaleable()): ?>
<li class="add-to-cart-textlink"><a href="#" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><span>Add to Cart</span></a></li>
<?php else: ?>
<li><?php echo $this->__('Out of stock') ?></li>
<?php endif; ?>
<?php if ($this->helper('wishlist')->isAllow()) : ?>
<li><a href="<?php echo $this->helper('wishlist')->getAddUrl($_product) ?>"><?php echo $this->__('Add to Wishlist') ?></a></li>
<?php endif; ?>
<?php if($_compareUrl=$this->getAddToCompareUrl($_product)): ?>
<li><a href="<?php echo $_compareUrl ?>"><?php echo $this->__('Add to Compare') ?></a></li>
<?php endif; ?>
</ul>
</td>
<?php if ($i%4==0 && $i!=$_collectionSize): ?>
</tr>
<?php endif ?>
<?php if ($i==4) break; // show 4 products max ?>
<?php endforeach ?>
<?php for($i;$i%4!=0;$i++): ?>
<td class="empty-product"> </td>
<?php endfor ?>
<?php if ($i%4==0): ?>
</tr>
<?php endif ?>
</table>
<script type="text/javascript">decorateTable('product-list-table')</script>
</div>
<?php endif; ?>
Quelqu'un pourrait-il s'il vous plaît me dire où je me trompe.
Merci d'avance
il ny a pas dans un fichier, il est dans le back-end de magento –
Vous ne pouvez pas ajouter un bloc dans la description de la catégorie. Au lieu de cela, vous pouvez affecter un bloc statique CMS à votre catégorie et ce bloc affichera vos produits aléatoires – Slimshadddyyy
cela signifie-t-il que je vais devoir créer un bloc statique pour chaque catégorie? –