當我使用的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