最模板 - 外贸网站建设,外贸网站模板

最模板

当前位置: 首页 > Magento > Magento教程 >

magento pdf打印分类产品

时间:2014-07-11 00:54来源:未知 作者:VCPHP网站模板 点击:
magento pdf打印分类产品,选择分类,打印分类下的产品为pdf格式 选择筛选属性,点击分类 即可下载pdf,pdf包含产品数据 app\code\More\Pdfproduct\controllers CategoryController.php ?php class More_Pdfprodu

magento pdf打印分类产品,选择分类,打印分类下的产品为pdf格式

pdf

 

选择筛选属性,点击分类 即可下载pdf,pdf包含产品数据

app\code\More\Pdfproduct\controllers  CategoryController.php
 

 
<?php
 
class More_Pdfproduct_CategoryController extends Mage_Core_Controller_Front_Action {
protected function _initCategoryLayout()
{
$update = $this->getLayout()->getUpdate();
$update->addHandle('default');
 
$this->addActionLayoutHandles();
$this->loadLayoutUpdates();
$this->generateLayoutXml()->generateLayoutBlocks();
$this->renderLayout();
}
 
public function viewAction()
{
$categoryId = (int) $this->getRequest()->getParam('id', false);
if ($categoryId) {
$this->_initCategoryLayout();
}
elseif (!$this->getResponse()->isRedirect()) {
$this->_forward('noRoute');
}
}
 
public function printAction()
{
$categoryId = (int) $this->getRequest()->getParam('id', false);
if ($categoryId) {
 
$this->_initCategoryLayout();
$root = $this->getLayout()->getBlock('root');
$html = $root->toHtml();
$category = Mage::getModel('catalog/category')->load($categoryId);
Mage::helper('pdfproduct/print')->PDFFrontendStreamToBrowser($html,$category->getUrl_key());
 
}
elseif (!$this->getResponse()->isRedirect()) {
$this->_forward('noRoute');
}
}
 
public function saveAction()
{
$categoryId = (int) $this->getRequest()->getParam('id', false);
if ($categoryId) {
 
$this->_initCategoryLayout();
$root = $this->getLayout()->getBlock('root');
$html = $root->toHtml();
$category = Mage::getModel('catalog/category')->load($categoryId);
 
 
Mage::helper('pdfproduct/print')->PDFFrontendSaveFile($html,$category->getUrl_key());
$this->getResponse()->setRedirect($this->_getRefererUrl());
return;
}
elseif (!$this->getResponse()->isRedirect()) {
$this->_forward('noRoute');
}
}
 
}
 
(责任编辑:最模板)
------分隔线----------------------------
栏目列表
推荐内容