西部数码主机 | 阿里云主机| 虚拟主机 | 服务器 | 返回乐道官网
当前位置: 主页 > php教程 > magento教程 >

magento pdf打印分类产品

时间:2016-02-02 10:45来源: 作者: 点击:
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');
}
}
 
}
 
(责任编辑:好模板)
顶一下
(0)
0%
踩一下
(0)
0%
------分隔线----------------------------
栏目列表
热点内容