Magento отдельный price.phtml - PullRequest
       14

Magento отдельный price.phtml

1 голос
/ 18 августа 2011

Как добавить новый шаблон цены в представление категории (template / catalog / product / list.phtml) без изменения шаблона цены, используемого в (template / catalog / product / view.phtml)?В обоих файлах используется шаблон / catalog / product / price.phtml, но мне нужен отдельный шаблон цен в template / catalog / product / list.phtml.

Ответы [ 2 ]

2 голосов
/ 18 августа 2011

Это не очень хорошее решение, но вы можете скопировать price.phtml в свою собственную тему, а затем проверить, находитесь ли вы на странице категории с:

$handles = $this->getLayout()->getUpdate()->getHandles();
if (array_search('catalog_category_view', $handles)) {
    echo 'here you can do other things';
}
1 голос
/ 18 августа 2011

Скопируйте app / code / core / Mage / Catalog / Block / Product.php в app / code / local / YourModule / Catalog / Block / Product.php (о деталях создания собственного модуля вы должны увидеть в другом документе ).

В скопированном файле, о строке 61, изменить

public function getPriceHtml($product)
    {
        $this->setTemplate('catalog/product/price.phtml');
        $this->setProduct($product);
        return $this->toHtml();
    }

до

public function getPriceHtml($product)
    {
        $this->setTemplate('catalog/product/your_price.phtml');
        $this->setProduct($product);
        return $this->toHtml();
    }

Вы можете настроить просмотр цены в your_price.phtml.

...