Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/magento/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Magento getProductCollection不工作。_Magento_Magento 1.7_Magento 1.4_Magento 1.5_Magento 1.6 - Fatal编程技术网

Magento getProductCollection不工作。

Magento getProductCollection不工作。,magento,magento-1.7,magento-1.4,magento-1.5,magento-1.6,Magento,Magento 1.7,Magento 1.4,Magento 1.5,Magento 1.6,这是我的Magento代码,用于获取所有新产品,但它突然停止工作。我添加了一些新的类别,然后当我看到前端新来的部分是空的。任何帮助都将不胜感激 这是我的密码: <?php if (($_products = $this->getProductCollection()) && $_products->getSize()): ?> <div class="new-products"> <div class="title_index">

这是我的Magento代码,用于获取所有新产品,但它突然停止工作。我添加了一些新的类别,然后当我看到前端新来的部分是空的。任何帮助都将不胜感激

这是我的密码:

<?php if (($_products = $this->getProductCollection()) && $_products->getSize()): ?>
<div class="new-products">

<div class="title_index">

<!-- <div class="pagination_carousel" id="foo3_pag"></div>-->
 <h2><?php echo $this->__('New Arrivals') ?></h2>
</div>

<div class="index_cont">

<div class="list_carousel">         

<ul id="user_interaction">

<?php $_columnCount = $this->getColumnCount(); ?>

<?php $i=0; foreach ($_products->getItems() as $_product): ?>        

<li><h3 class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>"><?php echo $this->htmlEscape($_product->getName()) ?></a></h3>
                                        <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>" class="product-image"><img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(220, 200) ?>" width="150" height="130" alt="<?php echo $this->htmlEscape($_product->getName()) ?>" /></a>

<div class="descr"><?php echo($_product->getSku()); ?></div>

<div class="new_price"><?php echo $this->getPriceHtml($_product, true, '-new') ?></div>

<div class="new_pr_btn"><input value="1" type="text" name="qty" class="my-qty-box" /><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></div>

                        </li>        

    <?php endforeach; ?>

                </ul>

                <div class="clear"></div>           

                </div>

</div>

<div class="shadow-div"></div>

</div>

<?php endif; ?>


  • $sql=$this->getProductCollection()->getSelect();将此代码放在phtml的顶部。 echo$sql; 这将向您展示SQLQQuery

    现在直接在phpMyAdmin或miniadmin中启动此查询,并检查是否有此查询的记录

    如果不诊断此sql查询,请考虑导致某些情况的过滤器,这将导致修复

    否则,请将sql查询粘贴到此处以获取更多注释


    注意:如果启用平面目录,则代码将检查平面目录表。因此,请检查这些表是否已填充所有产品。如果未运行索引。

    是否可以附加块的代码?是否重新索引/刷新缓存?$this->getProductCollection()的转储是什么?能否直接在数据库中执行块文件中获取的集合的MySQL语句?