2012-08-06 2 views
0

처음부터 하나의 템플릿을 만들려고합니다. 나는 모든 것을 이미 준비해 놓았고, 지금은 그리드에서 사용 가능한 모든 제품을 표시하고자하는 홈페이지를 가지고 있습니다. 그래서 레이아웃에서 list.phtml을 렌더링했습니다. list.phtml :이 제품 시간, 단어 productsample의 수를 표시합니다, 그래서 내가 좋은 모든 제품을로드하고 생각하지만, 내 문제는 내가 (을 표시하는 방법을 사진을 잘 모릅니다이다내 홈페이지의 모든 제품을 표시 - magento

<?php 
$_productCollection=$this->getLoadedProductCollection(); 

$_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> 
       productsample 
      </li> 


    <?php if ($i%$_columnCount==0 || $i==$_collectionSize): ?> 
     </ul> 
    <?php endif ?> 

<?php endforeach ?> 
</div> 
<?php endif; ?> 

, 링크 addToCart와, 가격, 이름 ...)에 덕분에 모든

+0

대신에이 코드를 넣어 바로 확인'응용 프로그램/디자인/프론트 엔드/기초/기본/카탈로그/제품/list.phtml' 파일 – Serjio

+0

은 내가했던 첫 번째 일은이었다 ,하지만 그것은 작동하지 않습니다 ... 그것은 내가 홈페이지에 있기 때문에 당신이 내게 말한 파일이 활성 카테고리의 제품을 보여 – Carlos

+0

그래, 내가 아는이 섹션에 제품이 없다는 것을 보여줍니다. 그러나 모든 제품의 데이터가 출력되는 'foreach'내에 코드를 복사하여 붙여 넣을 수 있습니다. 어쨌든'$ _product'에'getData()'메소드를 사용하면 거의 모든 제품 데이터를 출력 할 수 있습니다. – Serjio

답변

0

난 GetData의 사용할 때 이런 얻었다 :

어레이 (11) {[ "ENTITY_ID"] => 캐릭터 (1) "2" [ "type_id"] => 문자열 (6) "simple"[ "sku"] => 문자열은 다음과 같습니다 : [ "entity_type_id"] => 문자열 (1) "4"[ "attribute_set_id"] => (10) "1343918767"[ "has_options"] => 문자열 (1) "0"[ "req uired_options "] => 문자열 (1)"0 "["created_at "] => 문자열 (19)"2012-08-02 14:46:29 "["updated_at "] => string (19)"2012-08 -02 17:09:43 "["is_salable "] => 문자열 (1)"1 "["stock_item "] => 객체 (Varien_Object) # 336 (5) {["_ 데이터 ": 보호] => 1 "}" "_hasDataChanges": protected] => bool (false) [ "_origData": 보호] => NULL [ "_idFieldName": protected] => NULL [ "_isDeleted"보호] 내가이 sustituted 한

내가 이름, 가격을 필요로 ...

=> 부울}} (거짓) : $ _productCollection = $ this-> 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; ?> 

첫 < A> 당신이 CMS를 홈 페이지를 사용하는 경우 < 리 안에>,

0

작업의 IMG 밤은 그때 그냥이 코드 {{block type="catalog/product_list" category_id="your cat id" template="catalog/product/list.phtml"}} 할당을 넣어 모든 제품 여기에 코드입니다 이 카테고리에. 또는 list.phtml 파일 코드를 사용하여 코드 바로 아래에있는 모든 제품을 나열 할 수 있습니다.

$_productCollection = Mage::getModel('catalog/product')->getCollection()->addAttributeToSelect('*')->addAttributeToFilter('visibility', 4)->addAttributeToFilter('status', 1)->load(); 

바로 그래서이 $_productCollection=$this->getLoadedProductCollection();

관련 문제