Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/12.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
Php magento主页中的特色产品未使用模块显示_Php_Xml_Magento_Module - Fatal编程技术网

Php magento主页中的特色产品未使用模块显示

Php magento主页中的特色产品未使用模块显示,php,xml,magento,module,Php,Xml,Magento,Module,我想在主页上显示特色产品。因此我在app/code/local/FeaturedProduct/Catalog/block/product/featured.php中创建了自定义模块和块文件 代码: class FeaturedProduct_Catalog_Block_Product_Featured extends Mage_Catalog_Block_Product_Abstract { public function __construct() { $

我想在主页上显示特色产品。因此我在app/code/local/FeaturedProduct/Catalog/block/product/featured.php中创建了自定义模块和块文件

代码:

class FeaturedProduct_Catalog_Block_Product_Featured  extends Mage_Catalog_Block_Product_Abstract
{           


public function __construct()
{
    $this->setLimit(40);
    $sort_by = 'name';
    $this->setItemsPerRow(4);


    switch ($sort_by) {

        case 0:
            $this->setSortBy("rand()");
        break;
        case 1:
            $this->setSortBy("created_at desc");
        break;
        default:
            $this->setSortBy("rand()");     
    }
}

protected function _beforeToHtml()
{           
    $collection = Mage::getResourceModel('catalog/product_collection');

        $attributes = Mage::getSingleton('catalog/config')
            ->getProductAttributes();

        $collection->addAttributeToSelect($attributes)
            ->addMinimalPrice()
            ->addFinalPrice()
            ->addTaxPercents()
            ->addAttributeToFilter('featured_products', 1, 'left')
            ->addStoreFilter()
            ->getSelect()->order($this->getSortBy())->limit($this->getLimit());


        Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection);

        Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($collection);

        $this->_productCollection = $collection;

    $this->setProductCollection($collection);
    return parent::_beforeToHtml();
}

}
在app/code/local/FeaturedProduct/Catalog/etc/config.xml中创建了配置文件

代码:

加载主页后,它什么也不显示。不知道我哪里出错了。我不想更改local.xml,所以采取了这个方法。我还有什么事情要做或创建其他文件吗?请帮忙

编辑:

创建了模块配置文件app/etc/modules/FeaturedProduct_Catalog.xml,现在显示在admin-conf adva中

<?xml version="1.0"?>
<config>
<modules>
    <FeaturedProduct_Catalog>
        <active>true</active>
        <codePool>local</codePool>
    </FeaturedProduct_Catalog>
</modules>
</config>  

真的
地方的

这是特色产品的工作模块,请遵循

app/etc/modules/Solsint_.xml

<?xml version="1.0"?>
<config>
<modules>
    <Solsint_Featured>
        <active>true</active>
        <codePool>local</codePool>
    </Solsint_Featured>
</modules>
</config>

您是否能够在
system->configuration
选项卡
advanced
中看到您的模块,发布模块配置文件app/etc/modules/youfileupdated qn。。我添加了conf仍然没有结果我必须测试you模块代码,现在我看到了,没有找出问题所在。对此一无所知..致命错误:调用布尔值上的成员函数getBackend(),在哪个文件中设置了属性集中的属性?并将产品添加到general Group下的featured?dafault中我在第816行有3个featured productsmagento\app\code\core\Mage\Eav\Model\Entity\Abstract.php
<?php if (($_products = $this->getProductCollection()) && $_products->getSize()): ?>

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

<div class="new_product_slider">
<div id="demo">
<div class="text_left"><?php echo Mage::helper('featuredproducts')->getConfigHeading();?></div>
<div class="text_right"> <?php echo $this->__('Fragtfri ved køb over 130 kr.')?> </div>
<div class="clear"></div>
<div id="owl-demo1" class="owl-carousel">



<?php $i=1; foreach ($_products->getItems() as $_product): ?>
   <?php if($i > 1 ) { $j=2;} else { $j=1;} ?>

       <div class="item">
<ul>
<li>



             <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>" class="prod"><img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(183, 183) ?>" width="183" height="183" alt="<?php echo $this->htmlEscape($_product->getName()) ?>" /></a>

                  <div class="cover"
<a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>" > <?php echo strip_tags(ucfirst($this->htmlEscape($_product->getName()))) ?></a></div>
<h4><?php echo $this->getPriceHtml($_product, true, '-new') ?></h4>
<aside class="læs_btn"><a href="<?php echo $_product->getProductUrl() ?>"><span><?php echo $this->__('Læs mere'); ?></span></a></aside>
                   <div class="clear"></div>
</li>
</ul>
</div>
                   <?php $i++; if($i%5==0) { $i=1; ?>
            <?php  } ?>


<?php  endforeach; ?>
   </div>
</div>
</div>
{{block type="featuredproduct/product_collection" name="product_collection" as="product_collection" template="catalog/product/featured.phtml"}} 
<?xml version="1.0"?>
<config>
<modules>
    <FeaturedProduct_Catalog>
        <active>true</active>
        <codePool>local</codePool>
    </FeaturedProduct_Catalog>
</modules>
</config>  
<?xml version="1.0"?>
<config>
<modules>
    <Solsint_Featured>
        <active>true</active>
        <codePool>local</codePool>
    </Solsint_Featured>
</modules>
</config>
<!--?xml version="1.0" encoding="UTF-8"?-->
<config>
<modules>
<Solsint_Featured>
    <version>1.0.0</version>                        
</Solsint_Featured>
</modules>
<global>
    <blocks>
        <featured>
            <class>Solsint_Featured_Block</class>
        </featured>
    </blocks>
</global>
</config>
<?php 
class Solsint_Featured_Block_Product_Featured  extends Mage_Catalog_Block_Product_Abstract
{           


public function __construct()
{
    $this->setLimit(40);
    $sort_by = 'name';
    $this->setItemsPerRow(4);


    switch ($sort_by) {

        case 0:
            $this->setSortBy("rand()");
        break;
        case 1:
            $this->setSortBy("created_at desc");
        break;
        default:
            $this->setSortBy("rand()");     
    }
}

protected function _beforeToHtml()
{           
    $collection = Mage::getResourceModel('catalog/product_collection');

        $attributes = Mage::getSingleton('catalog/config')
            ->getProductAttributes();

        $collection->addAttributeToSelect($attributes)
            ->addMinimalPrice()
            ->addFinalPrice()
            ->addTaxPercents()
            ->addAttributeToFilter('featured_products', 1, 'left')
            ->addStoreFilter()
            ->getSelect()->order($this->getSortBy())->limit($this->getLimit());


        Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection);

        Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($collection);

        $this->_productCollection = $collection;

    $this->setProductCollection($collection);
    return parent::_beforeToHtml();
}

}
<?php 

if ($_products = $this->getProductCollection()): ?>

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

<div class="new_product_slider">
<div id="demo">
<div class="text_left"><?php //echo Mage::helper('featuredproducts')->getConfigHeading();?></div>
<div class="text_right"> <?php echo $this->__('Fragtfri ved køb over 130 kr.')?> </div>
<div class="clear"></div>
<div id="owl-demo1" class="owl-carousel">



<?php $i=1; foreach ($_products->getItems() as $_product): ?>
   <?php if($i > 1 ) { $j=2;} else { $j=1;} ?>

       <div class="item">
<ul>
<li>



             <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>" class="prod"><img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(183, 183) ?>" width="183" height="183" alt="<?php echo $this->htmlEscape($_product->getName()) ?>" /></a>

                  <div class="cover"
<a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>" > <?php echo strip_tags(ucfirst($this->htmlEscape($_product->getName()))) ?></a></div>
<h4><?php echo $this->getPriceHtml($_product, true, '-new') ?></h4>
<aside class="læs_btn"><a href="<?php echo $_product->getProductUrl() ?>"><span><?php echo $this->__('Læs mere'); ?></span></a></aside>
                   <div class="clear"></div>
</li>
</ul>
</div>
                   <?php $i++; if($i%5==0) { $i=1; ?>
            <?php  } ?>


<?php  endforeach; ?>
   </div>
</div>
</div>
<?php  endif; ?>
{{block type="featured/product_featured" name="product_collection" as="product_collection" template="catalog/product/featured.phtml"}}