제품에 속성이 있는지 확인하는지 확인하십시오.
-
12-12-2019 - |
문제
Bogof라는 속성이 있습니다.항목을 보여주기 위해 그림을 표시하는 방법이 있습니까?속성은 예 / 아니오입니다.
누군가가 과거 에이 코드를주었습니다.하지만 내 product_slider.phtml 파일에서 작동하지 않습니다
$quote = Mage::getSingleton('checkout/session')->getQuote();
$cartItems = $quote->getAllVisibleItems();
foreach ($cartItems as $item)
{
$productId = $item->getProductId();
$product = Mage::getModel('catalog/product')->load($productId);
if($product->getData('attributecode')==1){
//direct delivery possaible
}
}
.
나는 그것이 때문이라고 가정합니다.
$quote = Mage::getSingleton('checkout/session')->getQuote();
.
그러나 나는 그것을 일하기 위해 그것을 바꾸기 위해 그것을 바꾸는 방법을 모른다.
이것은 내 슬라이더에있는 제품을 보여주는 내 .phtml 파일입니다.
$cms_id = $this->helper('settings')->getCurrentCmsPage();
if ( !$cms_id ) {
$pageLayout = $this->getLayout()->getBlock('root')->getTemplate();
if ( strpos($pageLayout, '2columns') ) {
$grid_class = 'two_columns_' . Mage::getStoreConfig('settings/catalog/grid_columns_2col');
} else {
$grid_class = 'one_column_' . Mage::getStoreConfig('settings/catalog/grid_columns_1col');
}
} else {
if ( $cms_id == 'home' ) {
$grid_class = 'one_column_' . Mage::getStoreConfig('settings/catalog/grid_columns_1col');
} else {
$grid_class = 'two_columns_' . Mage::getStoreConfig('settings/catalog/grid_columns_2col');
}
}
$_productCollection=$this->getLoadedProductCollection();
$_helper = $this->helper('catalog/output');
$helper = $this->helper('settings/image');
$imgX = 252;
$imgY = $helper->calculateHeight($imgX);
$time = time() + mt_rand(0, 1000);
?>
<?php if($_productCollection->count()): ?>
<div class="product-slider-container">
<div class="clearfix title-container">
<h2><?php echo $this->__($this->getBlockTitle());?></h2>
<a href="#" class="jcarousel-prev-horizontal" id="carousel_prev<?php echo $time; ?>"></a>
<a href="#" class="jcarousel-next-horizontal" id="carousel_next<?php echo $time; ?>"></a>
</div>
<ul id="featured_<?php echo $time; ?>" class="products-grid jcarousel-skin-tango clearfix <?php echo $grid_class; ?>">
<?php foreach ($_productCollection as $_product): ?>
<li class="item">
<div class="regular">
<a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>" class="product-image">
<?php echo $this->helper('settings')->getLabel($_product); ?>
<img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize($imgX, $imgY) ?>" data-srcX2="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize($imgX*2, $imgY*2) ?>" width="<?php echo $imgX; ?>" height="<?php echo $imgY; ?>" alt="<?php echo $this->htmlEscape($_product->getName()) ?>" />
</a>
<div class="product-info">
<div class="button-container">
<?php if($_product->isSaleable()): ?>
<?php if (Mage::getStoreConfig('settings/ajax/cart')) : ?>
<?php if ( !($_product->getTypeInstance(true)->hasRequiredOptions($_product) || $_product->isGrouped()) ) { ?>
<p><button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button btn-cart ajax-cart" data-url="<?php echo $this->getAddToCartUrl($_product); ?>" data-id="<?php echo $_product->getId(); ?>"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button></p>
<?php } else { ?>
<p><button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button btn-cart show-options" data-id="<?php echo $_product->getId(); ?>"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button></p>
<?php } ?>
<?php else: ?>
<p><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></p>
<?php endif; ?>
<?php else: ?>
<p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
<?php endif; ?>
</div>
<?php $_productNameStripped = $this->stripTags($_product->getName(), null, true); ?>
<a class="product-name" href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $_productNameStripped; ?>"><?php echo $_helper->productAttribute($_product, $_product->getName() , 'name'); ?></a>
<?php echo $this->getPriceHtml($_product, true) ?>
</div>
</div>
.
고맙습니다
해결책
이 작업을 수행하는 방법을 알아 냈습니다. 내가해야 할 일은이 모든 것을 내 제품 이미지 주위에이면이 if 문을 감싸줍니다.
<?php if($_product->getData('bogof')==1){?>
<div class="bogof_image"></div>
<?php } ?>
.
클래스 "bogof_image"클래스의 CSS를 생성하여 내 상징의 배경 이미지가 있습니다.
제휴하지 않습니다 magento.stackexchange