Magento Мой блок пользовательских блоков не отображается

Я использую Magento 1.9.2.2 и пытаюсь создать модуль, который показывает список продуктов. Ниже мой текущий код, который не отображает блок. Я надеюсь, что кто-то может указать мне правильное направление, как это исправить.

приложение / и т.д. / модули / Envato_All.xml

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

Приложение / код / ​​местные / Envato / Recentproducts / и т.д. / config.xml

<?xml version="1.0"?>
<config>
<modules>
<Envato_Recentproducts>
<version>1.0</version>
</Envato_Recentproducts>
</modules>
<global>
<blocks>
<recentproducts>
<class>Envato_Recentproducts_Block</class>
</recentproducts>
</blocks>
<models>
<recentproducts>
<class>Envato_Recentproducts_Model</class>
</recentproducts>
</models>
</global>
</config>

Приложение / код / ​​местные / Envato / Recentproducts / Модель / Recentproducts.php

<?php
class Envato_Recentproducts_Model_Recentproducts extends Mage_Core_Model_Abstract
{
public function getRecentProduct()
{
$products = Mage::getModel("catalog/product")
->getCollection()
->addAttributeToSelect('*')
->setOrder('entity_id', 'DESC')
->setPageSize(5);
return $products;
}
}

Приложение / код / ​​местные / Envato / Recentproducts / Block / Recentproducts.php

<?php
class Envato_Recentproducts_Block_Recentproducts extends Mage_Core_Block_Template
{
public function getRecentProducts()
{
// call model to fetch data
$arr_products = array();
$products = Mage::getModel("recentproducts/recentproducts")­->getRecentProducts();

foreach ($products as $product) {
$arr_products[] = array(
'id' => $product-­>getId(),
'name' => $product­->getName(),
'url' => $product­->getProductUrl(),
);
}

return $arr_products;
}
}

приложение / дизайн / интерфейс / по умолчанию / по умолчанию / шаблон / recentproducts / recentproducts.phtml

<?php
$products = $this­->getRecentProducts();
?>

<div id="product_list">
<h1>Recent Products</h1>
<?php if (is_array($products) && count($products)) { ?>
<?php foreach($products as $product) { ?>
<div>
<a href="<?php echo $product['url'] ?>"><?php echo $product['name'] ?></a>
</div>
<?php } ?>
<?php } ?>
</div>

Используемый блок

{{block type="recentproducts/recentproducts" name="recentproducts_recentproducts" template="recentproducts/recentproducts.phtml"}}

0

Решение

Вы пытались добавить «недавние продукты / недавние продукты» и установить, чтобы разрешить в конфигурации-> разрешение-> Блоки?

не забудьте очистить кеш после добавления этого ..

Дай мне знать

1

Другие решения

Других решений пока нет …

По вопросам рекламы ammmcru@yandex.ru
Adblock
detector