我创建了一个phtml
文件,用于列出主页上的某些特定类别。我通过以下代码在CMS主页上调用了此文件:"{{block type="core/template" template="page/html/hometabs.phtml"}}"
,一切正常。
我想在名称后的自定义页面上显示颜色样本。
在list.phtml
中,通过布局文件夹中文件configurableswatches.xml
的此代码显示颜色样本:
<product_list>
<reference name="head">
<action method="addItem"><type>skin_js</type><name>js/configurableswatches/product-media.js</name></action>
<action method="addItem"><type>skin_js</type><name>js/configurableswatches/swatches-list.js</name></action>
</reference>
<reference name="product_list.name.after">
<block type="core/template" name="product_list.swatches" template="configurableswatches/catalog/product/list/swatches.phtml" />
</reference>
<reference name="product_list.after">
<block type="configurableswatches/catalog_media_js_list" name="configurableswatches.media.js.list" />
</reference>
</product_list>
我的phtml代码:
<div name="tab_content" id="tab_content_1" class="tab_content active ">
<?php
$categoryId = 8;
$collection = Mage::getSingleton('catalog/category')->load($categoryId)
->getProductCollection()->addAttributeToFilter('visibility', 4)
->addAttributeToSelect('*')->addAttributeToFilter('status',1);
$_collectionSize=$collection->count();
if($collection->count()>0):
?>
<?php $_columnCount = 4; ?>
<?php $i=0; ?>
<?php
$attributeOptions = array();
foreach($collection as $pro):
$productAttributeOptions = $pro->getTypeInstance(true)->getConfigurableAttributesAsArray($pro);
?>
<?php if ($i++%$_columnCount==0): ?>
<ul id="add-strip-tab<?php echo $hotSellercount++; ?>">
<?php endif ?>
<li>
<?php if($pro->getHotProduct() == 3){ ?>
<div class="sohot"><span class="sohot-text">so hot right now</span></div>
<?php } ?>
<figure>
<a href="<?php echo $pro->getProductUrl() ?>">
<img src="<?php echo Mage::helper('catalog/image')->init($pro, 'small_image')->resize(272,272); ?>" alt="<?php echo $pro->getName(); ?>">
</a>
</figure>
<h3 class="product-name"><?php echo $pro->getName(); ?></h3>
<div class="abc">
<?php echo $this->getLayout()->createBlock('core/template')->setTemplate('configurableswatches/catalog/product/list/swatches.phtml')->toHtml(); ?>
</div>
<?php if($pro->getSpecialPrice()){ ?>
<div class="price-box">
<p class="old-price">
<span class="price-label">Regular Price:</span>
<span class="price" ><?php echo Mage::helper('core')->currency($pro->getPrice(),true,false); ?></span>
</p>
<p class="special-price">
<span class="price-label">Special Price</span>
<span class="price" ><?php echo Mage::helper('core')->currency($pro->getSpecialPrice(),true,false); ?></span>
</p>
</div>
<?php } else {?>
<div class="price-box">
<p class="old-price">
<span class="price-label">Regular Price:</span>
<span class="" ><?php echo Mage::helper('core')->currency($coll->getPrice(),true,false); ?></span>
</p>
</div>
<?php }?>
</li>
<?php if ($i%$_columnCount==0 ): ?>
</ul>
<?php endif ?>
<?php endforeach; ?>
<?php else: ?>
<p class="note-msg"><?php echo $this->__('There are no products matching the selection.') ?></p>
<?php endif; ?>
</div>