0

I want to make a functionality by which a user can download file of any type from my magento store. I have displayed file link. Is there any magento default helper by which I can make it possible ?

1 Answer 1

1

please choose the correct file helper and make sure you using correct path on everywhere.

$linkfile = array();
$_highfilePath = $FolderPath.DS.$fname;
$linkfile[] = array(
        'file' => $filePath,
        'name' => $fname,
        'size' => filesize($filePath),
        'status' => 'new'
);

$linkFileName = Mage::helper('downloadable/file')->moveFileFromTmp(
            Mage_Downloadable_Model_Link::getBaseTmpPath(),
            Mage_Downloadable_Model_Link::getBasePath(),
            $linkfile
    );

    $linkModel = Mage::getModel('downloadable/link')->setData(array(
            'product_id' => $product->getId(),
            'sort_order' => 0,
            'number_of_downloads' => 0, // Unlimited downloads
            'is_shareable' => 2, // Not shareable
            'link_url' => '',
            'link_type' => 'file',
            'link_file' => json_encode($linkfile),
            'sample_url' => $SamplePathUrl,
            'sample_file' => json_encode($linkfile),
            'sample_type' => 'file',
            'use_default_title' => true,
            'default_price' => 0,
            'price' => 0,
            'store_id' => 0,
            'website_id' => $product->getStore()->getWebsiteId(),
    ));

hope i help you.

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.