$id = Mage::app()->getRequest()->getParam("id");
$name = explode("+", Mage::getModel('catalog/product')->load($id )->getName());
$_product = strtoupper(trim($name[0]));
$resource = Mage::getBaseDir().DS."media".DS."catalog".DS."product".DS."pdfs".DS.$_product.".pdf";
Note that this is very specific and might help you. The key code that I had to use was
Mage::app()->getRequest()->getParam("id");
and Mage::getModel('catalog/product')->load($id)->getName());
The "id" section can be replaced with $fileName= Mage::app()->getRequest()->getParam(\’file\’); and so forth. I got some of the information from http://www.magentocommerce.com/boards/viewthread/276949/#t381584 .
I also had to check a file app\code\local\Mage\Catalog\Block\Product\View\Pdf.php to contain the following
public function getPdfUrl(){
$name = explode(“+”, $this->getProduct()->getName());
$product_pdf = strtoupper(trim($name[0])).”.pdf”;
$product_id = $this->getProduct()->getId();
$file = Mage::getBaseDir().DS.”media”.DS.”catalog”.DS.”product”.DS.”pdfs”.DS.$product_pdf;
if(file_exists($file)){
$url = Mage::getUrl(“catalog/product/download/id/$product_id”);
return $url;
}
return false;
}
}
No comments:
Post a Comment