2016-07-11 12 views
1

Magento EE v1.14で作業していますが、ユーザーが製品ページを見て、在庫切れの場合に関連商品の色見本をドロップしたときの解決策を探しています。Magento関連製品の色見本

Screenshot: Highlighted out of stock related product color

Screenshot of HTML

PHP + HTMLコード:

<?php 

$_base_product = $this->getProduct(); 
$base_product = Mage::getModel('catalog/product')->load($_base_product->getId()); 
$base_product_id = $base_product->getId(); 
$base_name = $base_product->getName(); 
$base_url = Mage::getBaseUrl(); 

$product_colors = Mage::getModel('catalog/product')->getCollection(); 
$product_colors->addAttributeToFilter('status',1); // 1 or 2 
$product_colors->addAttributeToFilter('visibility',4); // 1.2.3.4 
$product_colors->addAttributeToFilter('name', array('eq' => $base_name)); 
$product_colors->addAttributeToFilter('sku', array('neq' => $base_product->getSku())); 


$product_colors_ids = $product_colors->getAllIds(); // get all products from the category 
sort($product_colors_ids); 

?> 

<?php if(count($product_colors_ids) > 0) : ?> 
    <div id="product-color-options-wrapper"> 
     <div id="product-color-options-container"> 
     <label><?php echo $this->__('Color') ?>/<span style="font-weight: normal;"><?php echo $base_product->getAttributeText('color'); ?></span></label> 
      <div id="color-options-wrapper"> 
       <?php $_swatch_img = $base_product->getMediaGalleryImages(false)->getItemByColumnValue('label', 'swatch') ?> 
       <?php if($_swatch_img) : ?> 
       <div class="current-product-wash-wrapper wash-wrapper"> 
        <div class="current-product-wash-container wash-container"> 
         <img src="<?php echo $this->helper('catalog/image')->init($base_product, 'small_image', $_swatch_img->getFile())->resize(33,30) ?>" alt="" title="<?php echo $base_product->getAttributeText('color') ?>" /> 
        </div> 
       </div> 
       <?php else : ?> 
        <!-- <span><?php echo $base_product->getColor() ?></span> --> 
       <?php endif ?> 
     <?php foreach($product_colors_ids as $prod_id) : ?> 
       <?php $_sister_product = Mage::getModel('catalog/product')->load($prod_id) ?> 
       <?php 
       $_sister_prod_imgs = $_sister_product->getMediaGallery('images'); 
       foreach($_sister_prod_imgs as $_sister_prod_img): 
        if($_sister_prod_img['label'] == 'swatch'): 
         $_swatch_img = $_sister_prod_img['file']; 
        endif; 
       endforeach; 
       ?> 
       <?php if($_swatch_img): ?> 
        <div class="sister-product-wrapper wash-wrapper"> 
         <div class="sister-product-container wash-container"> 
          <a href="<?php echo $base_url ?><?php echo $_sister_product->getUrlKey() ?>"> 
           <img src="<?php echo $this->helper('catalog/image')->init($_sister_product, 'small_image', $_swatch_img)->resize(33,30); ?>" alt="" title="<?php echo $_sister_product->getAttributeText('color') ?>"> 
          </a> 
         </div> 
        </div> 
       <?php endif; ?> 
     <?php endforeach ?> 
       <div class="clear"></div> 
      </div> 
     </div> 
    </div> 
<?php endif ?> 

任意の助けをいただければ幸いです! :

答えて

関連する問題