当前位置: 首页>>代码示例>>PHP>>正文


PHP Mage_Downloadable_Model_Sample::getBasePath方法代码示例

本文整理汇总了PHP中Mage_Downloadable_Model_Sample::getBasePath方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Downloadable_Model_Sample::getBasePath方法的具体用法?PHP Mage_Downloadable_Model_Sample::getBasePath怎么用?PHP Mage_Downloadable_Model_Sample::getBasePath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Mage_Downloadable_Model_Sample的用法示例。


在下文中一共展示了Mage_Downloadable_Model_Sample::getBasePath方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getSampleData

 /**
  * Retrieve samples array
  *
  * @return array
  */
 public function getSampleData()
 {
     $samplesArr = array();
     $samples = $this->getProduct()->getTypeInstance(true)->getSamples($this->getProduct());
     foreach ($samples as $item) {
         $tmpSampleItem = array('sample_id' => $item->getId(), 'title' => $item->getTitle(), 'sample_url' => $item->getSampleUrl(), 'sample_type' => $item->getSampleType(), 'sort_order' => $item->getSortOrder());
         $file = Mage::helper('downloadable/file')->getFilePath(Mage_Downloadable_Model_Sample::getBasePath(), $item->getSampleFile());
         if ($item->getSampleFile() && is_file($file)) {
             $tmpSampleItem['file_save'] = array(array('file' => $item->getSampleFile(), 'name' => Mage::helper('downloadable/file')->getFileFromPathFile($item->getSampleFile()), 'size' => filesize($file), 'status' => 'old'));
         }
         if ($this->getProduct() && $item->getStoreTitle()) {
             $tmpSampleItem['store_title'] = $item->getStoreTitle();
         }
         $samplesArr[] = new Varien_Object($tmpSampleItem);
     }
     return $samplesArr;
 }
开发者ID:jpbender,项目名称:mage_virtual,代码行数:22,代码来源:Samples.php

示例2: sampleAction

 /**
  * Download sample action
  *
  */
 public function sampleAction()
 {
     $sampleId = $this->getRequest()->getParam('sample_id', 0);
     $sample = Mage::getModel('downloadable/sample')->load($sampleId);
     if ($sample->getId()) {
         $resource = '';
         $resourceType = '';
         if ($sample->getSampleType() == Mage_Downloadable_Helper_Download::LINK_TYPE_URL) {
             $resource = $sample->getSampleUrl();
             $resourceType = Mage_Downloadable_Helper_Download::LINK_TYPE_URL;
         } elseif ($sample->getSampleType() == Mage_Downloadable_Helper_Download::LINK_TYPE_FILE) {
             $resource = Mage::helper('downloadable/file')->getFilePath(Mage_Downloadable_Model_Sample::getBasePath(), $sample->getSampleFile());
             $resourceType = Mage_Downloadable_Helper_Download::LINK_TYPE_FILE;
         }
         try {
             $this->_processDownload($resource, $resourceType);
             exit(0);
         } catch (Mage_Core_Exception $e) {
             $this->_getSession()->addError(Mage::helper('downloadable')->__('An error occurred while getting requested content. Please contact the store owner.'));
         }
     }
     return $this->_redirectReferer();
 }
开发者ID:evinw,项目名称:project_bloom_magento,代码行数:27,代码来源:DownloadController.php

示例3: getSampleData

 /**
  * Retrieve samples array
  *
  * @return array
  */
 public function getSampleData()
 {
     $samplesArr = array();
     if ($this->getProduct()->getTypeId() !== Mage_Downloadable_Model_Product_Type::TYPE_DOWNLOADABLE) {
         return $samplesArr;
     }
     $samples = $this->getProduct()->getTypeInstance()->getSamples($this->getProduct());
     $fileHelper = Mage::helper('Mage_Downloadable_Helper_File');
     foreach ($samples as $item) {
         $tmpSampleItem = array('sample_id' => $item->getId(), 'title' => $this->escapeHtml($item->getTitle()), 'sample_url' => $item->getSampleUrl(), 'sample_type' => $item->getSampleType(), 'sort_order' => $item->getSortOrder());
         $file = $fileHelper->getFilePath(Mage_Downloadable_Model_Sample::getBasePath(), $item->getSampleFile());
         if ($item->getSampleFile() && !is_file($file)) {
             Mage::helper('Mage_Core_Helper_File_Storage_Database')->saveFileToFilesystem($file);
         }
         if ($item->getSampleFile() && is_file($file)) {
             $tmpSampleItem['file_save'] = array(array('file' => $item->getSampleFile(), 'name' => $fileHelper->getFileFromPathFile($item->getSampleFile()), 'size' => filesize($file), 'status' => 'old'));
         }
         if ($this->getProduct() && $item->getStoreTitle()) {
             $tmpSampleItem['store_title'] = $item->getStoreTitle();
         }
         $samplesArr[] = new Varien_Object($tmpSampleItem);
     }
     return $samplesArr;
 }
开发者ID:natxetee,项目名称:magento2,代码行数:29,代码来源:Samples.php

示例4: save

 /**
  * Save Product downloadable information (links and samples)
  *
  * @param Mage_Catalog_Model_Product $product
  * @return Mage_Downloadable_Model_Product_Type
  */
 public function save($product = null)
 {
     parent::save($product);
     $product = $this->getProduct($product);
     /* @var Mage_Catalog_Model_Product $product */
     if ($data = $product->getDownloadableData()) {
         if (isset($data['sample'])) {
             $_deleteItems = array();
             foreach ($data['sample'] as $sampleItem) {
                 if ($sampleItem['is_delete'] == '1') {
                     if ($sampleItem['sample_id']) {
                         $_deleteItems[] = $sampleItem['sample_id'];
                     }
                 } else {
                     unset($sampleItem['is_delete']);
                     if (!$sampleItem['sample_id']) {
                         unset($sampleItem['sample_id']);
                     }
                     $sampleModel = Mage::getModel('downloadable/sample');
                     $files = array();
                     if (isset($sampleItem['file'])) {
                         $files = Mage::helper('core')->jsonDecode($sampleItem['file']);
                         unset($sampleItem['file']);
                     }
                     $sampleModel->setData($sampleItem)->setSampleType($sampleItem['type'])->setProductId($product->getId())->setStoreId($product->getStoreId());
                     if ($sampleModel->getSampleType() == Mage_Downloadable_Helper_Download::LINK_TYPE_FILE) {
                         $sampleFileName = Mage::helper('downloadable/file')->moveFileFromTmp(Mage_Downloadable_Model_Sample::getBaseTmpPath(), Mage_Downloadable_Model_Sample::getBasePath(), $files);
                         $sampleModel->setSampleFile($sampleFileName);
                     }
                     $sampleModel->save();
                 }
             }
             if ($_deleteItems) {
                 Mage::getResourceModel('downloadable/sample')->deleteItems($_deleteItems);
             }
         }
         if (isset($data['link'])) {
             $_deleteItems = array();
             foreach ($data['link'] as $linkItem) {
                 if ($linkItem['is_delete'] == '1') {
                     if ($linkItem['link_id']) {
                         $_deleteItems[] = $linkItem['link_id'];
                     }
                 } else {
                     unset($linkItem['is_delete']);
                     if (!$linkItem['link_id']) {
                         unset($linkItem['link_id']);
                     }
                     $files = array();
                     if (isset($linkItem['file'])) {
                         $files = Mage::helper('core')->jsonDecode($linkItem['file']);
                         unset($linkItem['file']);
                     }
                     $sample = array();
                     if (isset($linkItem['sample'])) {
                         $sample = $linkItem['sample'];
                         unset($linkItem['sample']);
                     }
                     $linkModel = Mage::getModel('downloadable/link')->setData($linkItem)->setLinkType($linkItem['type'])->setProductId($product->getId())->setStoreId($product->getStoreId())->setWebsiteId($product->getStore()->getWebsiteId())->setProductWebsiteIds($product->getWebsiteIds());
                     if (null === $linkModel->getPrice()) {
                         $linkModel->setPrice(0);
                     }
                     if ($linkModel->getIsUnlimited()) {
                         $linkModel->setNumberOfDownloads(0);
                     }
                     $sampleFile = array();
                     if ($sample && isset($sample['type'])) {
                         if ($sample['type'] == 'url' && $sample['url'] != '') {
                             $linkModel->setSampleUrl($sample['url']);
                         }
                         $linkModel->setSampleType($sample['type']);
                         $sampleFile = Mage::helper('core')->jsonDecode($sample['file']);
                     }
                     if ($linkModel->getLinkType() == Mage_Downloadable_Helper_Download::LINK_TYPE_FILE) {
                         $linkFileName = Mage::helper('downloadable/file')->moveFileFromTmp(Mage_Downloadable_Model_Link::getBaseTmpPath(), Mage_Downloadable_Model_Link::getBasePath(), $files);
                         $linkModel->setLinkFile($linkFileName);
                     }
                     if ($linkModel->getSampleType() == Mage_Downloadable_Helper_Download::LINK_TYPE_FILE) {
                         $linkSampleFileName = Mage::helper('downloadable/file')->moveFileFromTmp(Mage_Downloadable_Model_Link::getBaseSampleTmpPath(), Mage_Downloadable_Model_Link::getBaseSamplePath(), $sampleFile);
                         $linkModel->setSampleFile($linkSampleFileName);
                     }
                     $linkModel->save();
                 }
             }
             if ($_deleteItems) {
                 Mage::getResourceModel('downloadable/link')->deleteItems($_deleteItems);
             }
             if ($this->getProduct($product)->getLinksPurchasedSeparately()) {
                 $this->getProduct($product)->setIsCustomOptionChanged();
             }
         }
     }
     return $this;
 }
开发者ID:xiaoguizhidao,项目名称:emporiodopara,代码行数:100,代码来源:Type.php

示例5: save

 /**
  * Enter description here...
  *
  * @return Mage_Downloadable_Model_Product_Type
  */
 public function save()
 {
     parent::save();
     $product = $this->getProduct();
     /* @var Mage_Catalog_Model_Product $product */
     if ($data = $product->getDownloadableData()) {
         if (isset($data['sample'])) {
             $_deleteItems = array();
             foreach ($data['sample'] as $sampleItem) {
                 if ($sampleItem['is_delete'] == '1') {
                     if ($sampleItem['sample_id']) {
                         $_deleteItems[] = $sampleItem['sample_id'];
                     }
                 } else {
                     unset($sampleItem['is_delete']);
                     if (!$sampleItem['sample_id']) {
                         unset($sampleItem['sample_id']);
                     }
                     $sampleModel = Mage::getModel('downloadable/sample');
                     $files = array();
                     if (isset($sampleItem['file'])) {
                         $files = Zend_Json::decode($sampleItem['file']);
                         unset($sampleItem['file']);
                     }
                     $sampleModel->setData($sampleItem)->setSampleType($sampleItem['type'])->setProductId($product->getId())->setStoreId($product->getStoreId());
                     $fileStatusNew = false;
                     if (isset($files[0]) && $sampleModel->getSampleType() == Mage_Downloadable_Helper_Download::LINK_TYPE_FILE) {
                         $sampleModel->setSampleFile($files[0]['file']);
                         if ($files[0]['status'] == 'new') {
                             $fileStatusNew = true;
                         }
                     }
                     $sampleModel->save();
                     if ($sampleModel->getSampleType() == Mage_Downloadable_Helper_Download::LINK_TYPE_FILE && $fileStatusNew) {
                         try {
                             Mage::helper('downloadable/file')->moveFileFromTmp(Mage_Downloadable_Model_Sample::getBaseTmpPath(), Mage_Downloadable_Model_Sample::getBasePath(), $files[0]['file']);
                         } catch (Exception $e) {
                             Mage::throwException(Mage::helper('downloadable')->__('An error occurred while saving the file(s).'));
                         }
                     }
                 }
             }
             if ($_deleteItems) {
                 Mage::getResourceModel('downloadable/sample')->deleteItems($_deleteItems);
             }
         }
         if (isset($data['link'])) {
             $_deleteItems = array();
             foreach ($data['link'] as $linkItem) {
                 if ($linkItem['is_delete'] == '1') {
                     if ($linkItem['link_id']) {
                         $_deleteItems[] = $linkItem['link_id'];
                     }
                 } else {
                     unset($linkItem['is_delete']);
                     if (!$linkItem['link_id']) {
                         unset($linkItem['link_id']);
                     }
                     $files = array();
                     if (isset($linkItem['file'])) {
                         $files = Zend_Json::decode($linkItem['file']);
                         unset($linkItem['file']);
                     }
                     $sample = array();
                     if (isset($linkItem['sample'])) {
                         $sample = $linkItem['sample'];
                         unset($linkItem['sample']);
                     }
                     $linkModel = Mage::getModel('downloadable/link')->setData($linkItem)->setLinkType($linkItem['type'])->setProductId($product->getId())->setStoreId($product->getStoreId())->setWebsiteId($product->getStore()->getWebsiteId());
                     if (null === $linkModel->getPrice()) {
                         $linkModel->setPrice(0);
                     }
                     if ($linkModel->getIsUnlimited()) {
                         $linkModel->setNumberOfDownloads(0);
                     }
                     $fileStatusNew = false;
                     if (isset($files[0]) && $linkModel->getLinkType() == Mage_Downloadable_Helper_Download::LINK_TYPE_FILE) {
                         $linkModel->setLinkFile($files[0]['file']);
                         if ($files[0]['status'] == 'new') {
                             $fileStatusNew = true;
                         }
                     }
                     $sampleFileNew = false;
                     if ($sample && isset($sample['type'])) {
                         if ($sample['type'] == 'url' && $sample['url'] != '') {
                             $linkModel->setSampleUrl($sample['url'])->setSampleType($sample['type']);
                         }
                         $sampleFile = Zend_Json::decode($sample['file']);
                         if ($sample['type'] == Mage_Downloadable_Helper_Download::LINK_TYPE_FILE && isset($sampleFile[0])) {
                             $linkModel->setSampleFile($sampleFile[0]['file'])->setSampleType($sample['type']);
                             if ($sampleFile[0]['status'] == 'new') {
                                 $sampleFileNew = true;
                             }
                         }
                     }
//.........这里部分代码省略.........
开发者ID:albertobraschi,项目名称:magento-design-training,代码行数:101,代码来源:Type.php

示例6: getSampleFileName

 /**
  * Get sample file name
  *
  * @param array $sampleModel            
  * @param array $sample            
  * @return string $sampleFileName
  */
 public function getSampleFileName($sampleModel, $sample)
 {
     $sampleFileName = '';
     if ($sampleModel->getSampleType() == Mage_Downloadable_Helper_Download::LINK_TYPE_FILE) {
         $sampleFileName = Mage::helper('downloadable/file')->moveFileFromTmp(Mage_Downloadable_Model_Sample::getBaseTmpPath(), Mage_Downloadable_Model_Sample::getBasePath(), $sample);
     }
     return $sampleFileName;
 }
开发者ID:igorvasiliev4,项目名称:magento_code,代码行数:15,代码来源:Market.php


注:本文中的Mage_Downloadable_Model_Sample::getBasePath方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。