문제

제품 목록 페이지에서 번들 제품의 모든 이미지 (제품)를 보여주고 싶습니다. 마젠토 기능이 있으므로,이를 안내하십시오.

4 개의 항목이있는 번들 제품을 만들었습니다. A, B, C, D

이제 제품 목록 페이지에서 나는이 제품의 모든 4 개의 small_images를 보여주고 싶습니다.

어떻게 할 수 있습니까?

도움이 되었습니까?

해결책

시도 :

 $model= Mage::getModel('catalog/product');
 //$product is a product object
 if($product->getTypeId() == 'bundle'){
    $bundles = $product->getTypeInstance(true)->getChildrenIds($product->getId(), false);

    $item = array();
    foreach($bundles as $index => $items){
        foreach($items as $id){
            $item[] = $id;
            //break; //only get first item
            //un-comment above line if you want only one (first) item.
        }
    }

    if($item){
          $child = $model
                    ->getCollection()
                    ->addAttributeToSelect(array('name', 'price', 'image', 'small_image'))
                    ->addAttributeToFilter('entity_id', array('in' => $item))
                    ->setOrder('price', 'DESC')
                    ->load()
                    ;
    }

   foreach($child as $item){
        echo $item->getName();
        echo "<br>";
        echo '<img id="image" src="'.$this->helper('catalog/image')->init($item, 'small_image')->keepAspectRatio(true)->keepFrame(false)->resize(120, 100).'" alt="'.$_helper->productAttribute($item, $item->getName(), 'name').'"/>';
        echo "<br>";
        echo "<br>";
   }
}
.

키 포인트

  1. $product는 제품 객체입니다.
  2. 이것은 작동해야합니다.행운을 빕니다.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 magento.stackexchange
scroll top