0

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?

3 Answers 3

1

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);
}
6
  • found the title, literally just a string Commented Oct 28, 2015 at 9:23
  • edited my answer, it should work now Commented Oct 28, 2015 at 9:47
  • <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
  • get 404 not found Commented Oct 28, 2015 at 10:50
  • 1
    <a href="<?php echo Mage::getUrl('downloadable/download/sample', array('sample_id' => $_link->getId())); ?>"><?php echo ($_link->getTitle()); ?></a> try this way Commented Oct 28, 2015 at 10:57
1

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()
            );
        }
1
  • use my answer to fix your own for reference if someone else looks @ this question Commented Oct 28, 2015 at 10:28
0

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()
            );


        }
1
  • you can up-vote if that work for you
    – Abdul
    Commented Oct 28, 2015 at 10:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.