2013-09-02 3 views
2

다운로드 할 수있는 제품에 대한 링크를 프로그래밍 방식으로 추가하려고합니다. 아래 코드는 제가 작업하고있는 코드입니다.다운로드 할 수있는 제품 : 프로그래밍 방식으로 다운로드 할 수있는 제품에 파일 링크 추가

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

는이 내가 An error occurred while saving the file(s).를 얻을 오류입니다. 도와주세요

답변

0

추가 정보없이 확실하게 진단 할 수 없습니다. 여기에 실패 년대 호출에 대한 코드입니다 :

/** 
* Checking file for moving and move it 
* 
* @param string $baseTmpPath 
* @param string $basePath 
* @param array $file 
* @return string 
*/ 
public function moveFileFromTmp($baseTmpPath, $basePath, $file) 
{ 
    if (isset($file[0])) { 
     $fileName = $file[0]['file']; 
     if ($file[0]['status'] == 'new') { 
      try { 
       $fileName = $this->_moveFileFromTmp(
        $baseTmpPath, $basePath, $file[0]['file'] 
       ); 
      } catch (Exception $e) { 
       Mage::throwException(Mage::helper('downloadable')->__('An error occurred while saving the file(s).')); 
      } 
     } 
     return $fileName; 
    } 
    return ''; 
} 

, 파일 시스템 권한을 확인하게 될 것입니다 시작하는 좋은 장소가 있는지 당신의 데이터 유형이 함수 설명에 지정된 유형과 일치, 그리고 모든 파일과 디렉토리가 존재 확인하고.

관련 문제