php 产品页面上相同类别的产品不包括产品ID
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php 产品页面上相同类别的产品不包括产品ID相关的知识,希望对你有一定的参考价值。
{{block type="core/template" products_count="3" category_id="3" name="products-from-category" template="catalog/product/product-upgraded-models.phtml"}}
<?php
$_helper = $this->helper('catalog/output');
$currentproduct = Mage::registry('current_product');
$currentCategoryId = $this->getcategory_id();
$productsCount = $this->getproducts_count();
$currentcategory = '';
if($currentCategoryId){
$currentcategory = Mage::getModel('catalog/category')->load($currentCategoryId);
}
if(empty($productsCount)){ $productsCount = 3; }
if(!empty($currentcategory) && !empty($currentproduct) ):
?>
<?php
$_productCollection = $currentcategory->getProductCollection()
->addAttributeToFilter('status', 1)
->addAttributeToFilter('visibility', 4)
->addAttributeToSelect('*')
->addIdFilter(array($currentproduct->getId()), true)
->setPageSize($productsCount);
Mage::getModel('catalog/layer')->prepareProductCollection($_productCollection);
?>
<?php if(count($_productCollection)) : ?>
<ul>
<?php foreach ($_productCollection as $_product): $_product = Mage::getModel('catalog/product')->load($_product->getId()); ?>
<li class="item light-gray">
<img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(230,306); ?>" width="230" height="306" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" />
<h3><a href="<?php echo $_product->getProductUrl() ?>"><?php echo $_helper->productAttribute($_product, $_product->getName(), 'name') ?></a></h3>
<ul>
<li><i class="fa fa-check"></i> Aluminum Construction</li>
<li><i class="fa fa-check"></i> GoWorx Signature Style</li>
</ul>
<div class="price-box">
<span class="regular-price"><span class="price"><?php echo Mage::app()->getLocale()->currency(Mage::app()->getStore()->getCurrentCurrencyCode())->getSymbol().number_format($_product->getFinalPrice(), 2) ?></span></span>
</div>
<div class="actions">
<button class="button btn-cart" onclick="setLocation('<?php echo $_product->getProductUrl() ?>')" title="LEARN MORE" type="button"><span><span><?php echo $this->__('LEARN MORE'); ?></span></span></button>
</div>
<em>Typically ships within 24 hours</em>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
<?php endif; ?>
以上是关于php 产品页面上相同类别的产品不包括产品ID的主要内容,如果未能解决你的问题,请参考以下文章