gpt4 book ai didi

magento - 特价未显示在类别页面上

转载 作者:行者123 更新时间:2023-12-03 07:54:17 25 4
gpt4 key购买 nike

我为产品增加了特价。它在产品详细信息页面上显示特价,但不在类别页面上显示。如果我在list.phtml上调用specialprice,则它仅显示0。我认为需要对list.php进行一些更改。

代码如下:-
在list.php我的功能是

 protected function _getProductCollection()
{
if (is_null($this->_productCollection)) {
$layer = $this->getLayer();
/* @var $layer Mage_Catalog_Model_Layer */
if ($this->getShowRootCategory()) {
$this->setCategoryId(Mage::app()->getStore()->getRootCategoryId());
}

// if this is a product view page
if (Mage::registry('product')) {
// get collection of categories this product is associated with
$categories = Mage::registry('product')->getCategoryCollection()
->setPage(1, 1)
->load();
// if the product is associated with any category
if ($categories->count()) {
// show products from this category
$this->setCategoryId(current($categories->getIterator()));
}
}

$origCategory = null;
if ($this->getCategoryId()) {
$category = Mage::getModel('catalog/category')->load($this->getCategoryId());
if ($category->getId()) {
$origCategory = $layer->getCurrentCategory();
$layer->setCurrentCategory($category);
$this->addModelTags($category);
}
}

$this->_productCollection = $layer->getProductCollection();

$this->prepareSortableFieldsByCategory($layer->getCurrentCategory());

if ($origCategory) {
$layer->setCurrentCategory($origCategory);
}



}


return $this->_productCollection;
}

list.phtml
  <?php
$_productCollection=$this->getLoadedProductCollection();
$_helper = $this->helper('catalog/output');

<?php // Grid Mode ?>

<?php $_collectionSize = $_productCollection->count() ?>
<?php $_columnCount = $this->getColumnCount(); ?>
<div class="products-grid">
<div class="row">
<?php $i=0; foreach ($_productCollection as $_product):
$id_product = Mage::getModel('catalog/product')->load($_product->getId());
//$count_input_qty++;
$now = date("Y-m-d");
$newsFrom = substr($_product->getData('news_from_date'), 0, 10);
$newsTo = substr($_product->getData('news_to_date'), 0, 10);

$specialprice = Mage::getModel('catalog/product')->load($_product->getId())->getSpecialPrice();
//echo $specialprice . '-hau<br/>';
$price = Mage::getModel('catalog/product')->load($_product->getId())->getPrice();
if ($specialprice == '') {
$store_id = Mage::app()->getStore()->getStoreId();
$discounted_price = Mage::getResourceModel('catalogrule/rule')->getRulePrice(
Mage::app()->getLocale()->storeTimeStamp($store_id),
Mage::app()->getStore($store_id)->getWebsiteId(),
Mage::getSingleton('customer/session')->getCustomerGroupId(),
$_product->getId());
$specialprice = $discounted_price;

}
?>
<?php if ($i++%$_columnCount==0): ?>

<?php endif ?>

<div class="item col-lg-4 col-md-4 col-sm-6 col-xs-6 respl-item">
<div class="item-inner">
<div class="w-image-box">
<div class="item-image">
<!--SHOW 2 IMAGE FOR PRODUCTS-->
<?php $_media = Mage::getModel('catalog/product')->load($_product->getId())->getMediaGalleryImages() ?>

<?php $count_item=0; $check_img=0;?>

<?php $check_img = count($_media);?>

<a class="<?php if ($check_img >= 2) echo $this->__('rspl-image');?>" href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>">
<img class="first_image" src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(270); ?>" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" />

<?php if ($check_img >= 2): ?>
<?php
$flag=0;
foreach($_media as $_img): ?>
<?php $count_item++;?>
<?php if ($_img->getFile() == $_product->getSmallImage()){
if($count_item==$check_img){
$flag = 0;
}else{
$flag = 1;
}
continue;
} ?>
<?php if($flag==1) { ?>
<img class="last_image" src="<?php echo $this->helper('catalog/image')->init($_product, 'image', $_img->getFile())->constrainOnly(true)->keepAspectRatio(true)->keepFrame(false)->resize(270,270); ?>" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true); ?>" />
<?php break; }?>
<?php endforeach; ?>
<?php
if($flag==0){
foreach($_media as $_img){ ?>
<img class="last_image" src="<?php echo $this->helper('catalog/image')->init($_product, 'image', $_img->getFile())->constrainOnly(true)->keepAspectRatio(true)->keepFrame(false)->resize(270,270); ?>" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true); ?>" />
<?php break; }
}
?>
<?php endif?>
<!--END SHOW 2 IMAGE FOR PRODUCTS-->
</a>



</div>
<?php if ($newsFrom != "" && $now >= $newsFrom && ($now <= $newsTo || $newsTo == "")) { ?>
<div class="new-product">
<?php echo $this->__('New'); ?>
</div>
<?php }?>
<?php if ($specialprice) { ?>
<div class='sale-item'>
<?php echo $this->__('Sale'); ?>
</div>
<?php }?>
</div>
<div class="item-info">
<div class="item-title ">
<a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($_product->getName(), null, true) ?>">
<?php if( strlen($_helper->productAttribute($_product, $_product->getName(), 'name')) > 100 ){
echo substr($_helper->productAttribute($_product, $_product->getName(), 'name'), 0, 100);
} else {
echo $_helper->productAttribute($_product, $_product->getName(), 'name');
}?>
</a>
</div>
<div class="item-review">
<?php echo $this->getReviewsSummaryHtml($_product, "short", true); ?>
</div>

<div class="item-price">
<?php // echo $this->getPriceHtml($_product, true) ?>
<?php echo $this->getPriceHtml($_product, true) ?>
</div>
<!--
<div class="item-desc">
<?php
echo substr($_helper->productAttribute($_product, $_product->getShortDescription(), 'short_description'), 0, 70);
?>
</div>
-->
<div class="item-addto-wrap">
<div class="button-action item-addcart">
<?php if($_product->isSaleable()): ?>
<a class="button btn-cart" title="<?php echo $this->__('Add to Cart') ?>" href="javascript:void(0);" onclick="setLocation('<?php echo $this->getAddToCartUrl($id_product) ?>')">
<?php echo $this->__('Add to Cart') ?>
</a>
<?php else: ?>
<p class="availability out-of-stock">
<span><?php echo $this->__('Out of stock') ?> </span>
</p>
<?php endif; ?>

<?php if( $_compareUrl=$this->getAddToCompareUrl($_product) ): ?>
<a class="link-compare" href="<?php echo $_compareUrl ?>" title="<?php echo $this->__('Add to Compare'); ?>">
<?php echo $this->__('Add to Compare') ?>
</a>
<?php endif;?>

<?php if ( $this->helper('wishlist')->isAllow() ) : ?>
<a class="link-wishlist" href="<?php echo $this->helper('wishlist')->getAddUrl($_product) ?>" title="<?php echo $this->__('Add to Wishlist') ?>">
<?php echo $this->__('Add to Wishlist') ?>
</a>
<?php endif; ?>


</div>
</div>
</div>

</div>

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

<?php endif ?>
<?php endforeach ?>
</div>
</div>
<script type="text/javascript">decorateGeneric($$('ul.products-grid'), ['odd','even','first','last'])</script>
<?php endif; ?>

建议我,我该怎么办?

最佳答案

即使"Category Products"Status = Ready重新索引Update Required = NO

关于magento - 特价未显示在类别页面上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29469342/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com