当我使用的GetData我获得此:
阵列(11){[ “ENTITY_ID”] =>串(1) “2” [“entity_type_id”] => string(1)“4”[“attribute_set_id”] => string(2)“10”[“type_id”] => string(6)“simple”[“sku”] => string (10)“1343918767”[“has_options”] =>字符串(1)“0”[“req uired_options“] => string(1)”0“[”created_at“] => string(19)”2012-08-02 14:46:29“[”updated_at“] => string(19)”2012-08 -02 17:09:43“[”is_salable“] => string(1)”1“[”stock_item“] => object(Varien_Object)#336(5){[”_data“:protected] => array( 1){[“is_in_stock”] => string(1)“1”} [“_hasDataChanges”:protected] => bool(false)[“_origData”:protected] => NULL [“_idFieldName”:protected] => NULL [ “_isDeleted”:保护]
我需要的名称,价格......
我已经取代度这=>布尔(假)}}:$ _productCollection = $这个 - > getLoadedProductCollection();作为交换条件:$ _productCollection = Mage :: getModel('catalog/product') - > getCollection();
因为如果我使用第一个,它显示我在实际类别中没有产品。
然后我在foreach里面的foreach里默认list.phtm里面的代码,但它没有显示我的产品。产品img中存在某种错误,因为它停留在第一个产品中,在其图像中。这里是代码:
代码:
<?php
// $_productCollection=$this->getLoadedProductCollection();
$_productCollection=Mage::getModel('catalog/product')->getCollection();
$_helper = $this->helper('catalog/output');
?>
<?php if(!$_productCollection->count()): ?>
<p class="note-msg"><?php echo $this->__('There are no products matching the selection.') ?></p>
<?php else: ?>
<div class="category-products">
<?php // Grid Mode ?>
<?php $_collectionSize = $_productCollection->count() ?>
<?php $_columnCount = $this->getColumnCount(); ?>
<?php $i=0; foreach ($_productCollection as $_product): ?>
<?php if ($i++%$_columnCount==0): ?>
<ul class="products-grid">
<?php endif ?>
<li class="item<?php if(($i-1)%$_columnCount==0): ?> first<?php elseif($i%$_columnCount==0): ?> last<?php endif; ?>">
<a href="<?php echo $_product->getProductUrl() ?>" class="product-image"><img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(135); ?>" width="135" height="135" /></a>
<h2 class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($_product->getName(), null, true) ?>"><?php echo $_helper->productAttribute($_product, $_product->getName(), 'name') ?></a></h2>
<?php if($_product->getRatingSummary()): ?>
<?php echo $this->getReviewsSummaryHtml($_product, 'short') ?>
<?php endif; ?>
<?php echo $this->getPriceHtml($_product, true) ?>
<div class="actions">
<?php if($_product->isSaleable()): ?>
<button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button>
<?php else: ?>
<p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
<?php endif; ?>
<ul class="add-to-links">
<?php if ($this->helper('wishlist')->isAllow()) : ?>
<li><a href="<?php echo $this->helper('wishlist')->getAddUrl($_product) ?>" class="link-wishlist"><?php echo $this->__('Add to Wishlist') ?></a></li>
<?php endif; ?>
<?php if($_compareUrl=$this->getAddToCompareUrl($_product)): ?>
<li><span class="separator">|</span> <a href="<?php echo $_compareUrl ?>" class="link-compare"><?php echo $this->__('Add to Compare') ?></a></li>
<?php endif; ?>
</ul>
</div>
</li>
<?php if ($i%$_columnCount==0 || $i==$_collectionSize): ?>
</ul>
<?php endif ?>
<?php endforeach ?>
</div>
<?php endif; ?>
第一<一>中< LI>,其IMG心不是工作
所以,只检查'应用程序/设计/前端/基/默认/目录/产品/ list.phtml'文件 – Serjio 2012-08-06 14:49:35
这是我做的第一件事,但它没有工作....它表明,这部分没有产品,因为我在主页和你告诉我的文件显示活动类别的产品 – Carlos 2012-08-06 14:58:29
是的,我知道。但是,您可以将代码复制粘贴到'foreach'中,在那里输出所有产品的数据。无论如何,在'$ _product'上使用'getData()'方法,您将能够输出几乎所有的产品数据 – Serjio 2012-08-06 15:08:10