Skip to content

Commit a8709a5

Browse files
authored
Merge pull request #388 from sprankhub/create-downloadable-dir
create downloadable/files/links directory if it does not exist yet
2 parents 64a120d + 50bf0a6 commit a8709a5

File tree

1 file changed

+14
-5
lines changed
  • src/app/code/community/AvS/FastSimpleImport/Model/Import/Entity

1 file changed

+14
-5
lines changed

src/app/code/community/AvS/FastSimpleImport/Model/Import/Entity/Product.php

+14-5
Original file line numberDiff line numberDiff line change
@@ -1612,17 +1612,26 @@ protected function _getUploader()
16121612
}
16131613

16141614
/**
1615-
* @param $filePath
1615+
* @param $fileName
16161616
* @return bool
16171617
*/
16181618
protected function moveDownloadableFile($fileName)
16191619
{
1620-
$filePath = $this->_getUploader()->getTmpDir() . $fileName;
1621-
$destDir = Mage::getConfig()->getOptions()->getMediaDir() . '/downloadable/files/links' . $fileName;
1622-
1620+
$filePath = $this->_getUploader()->getTmpDir() . $fileName;
1621+
$basePath = Mage::getModel('downloadable/link')->getBasePath();
1622+
$destDirectory = dirname(Mage::helper('downloadable/file')->getFilePath($basePath, $fileName));
1623+
// make sure that the destination directory exists!
1624+
$ioObject = new Varien_Io_File();
1625+
try {
1626+
$ioObject->open(array('path' => $destDirectory));
1627+
} catch (Exception $e) {
1628+
$ioObject->mkdir($destDirectory, 0777, true);
1629+
$ioObject->open(array('path' => $destDirectory));
1630+
}
1631+
$destFile = $basePath . DS . $fileName;
16231632
$sourceFile = realpath($filePath);
16241633
if ($sourceFile !== false) {
1625-
return copy($sourceFile, $destDir);
1634+
return copy($sourceFile, $destFile);
16261635
} else {
16271636
return false;
16281637
}

0 commit comments

Comments
 (0)