I'm using a module called Intellimage_Attachs, what I want to do is get the files that I have attached to a product, how would I do this?
Have tried things like:
$product->getAttachs();
$product->getDownloadable();
But no luck any ideas?
I am not sure this will work or not, But I checked your extension and it is creating an additional attribute called samples_title
try this way
$product = Mage::getModel('catalog/product')->load($productID);
$typeInstance = $product->getTypeInstance(true);
$product->setTypeInstance(Mage::getModel('attachs/product_type', $typeInstance), true);
$samples = $product->getTypeInstance(true)->getSamples($product);
foreach ($samples as $_link)
{
print_r($_link);
}
<a href='http://www.mywebsite.com/media/downloadable/files/samples".$_link->getData('sample_file')."'>Here </a>";
doesnt work
Commented
Oct 28, 2015 at 10:49
I am not sure but try bellow functions
$samples = product->getTypeInstance(Mage::getModel('attachs/product_type', $typeInstance), true);
foreach ($samples as $item) {
$file = Mage::helper('downloadable/file')->getFilePath(
Mage_Downloadable_Model_Sample::getBasePath(), $item->getSampleFile()
);
}
Managed to solve this myself with help from Abdul;
$get_downloads = Mage::getModel('downloadable/product_type');
$get_downloads->setProduct($product);
$downloads = $get_downloads->getSamples();
foreach ($downloads as $download) {
$file = Mage::helper('downloadable/file')->getFilePath(
Mage_Downloadable_Model_Sample::getBasePath(), $download->getSampleFile()
);
}