本文整理汇总了PHP中Mage_Downloadable_Model_Link::getBaseSamplePath方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Downloadable_Model_Link::getBaseSamplePath方法的具体用法?PHP Mage_Downloadable_Model_Link::getBaseSamplePath怎么用?PHP Mage_Downloadable_Model_Link::getBaseSamplePath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Downloadable_Model_Link
的用法示例。
在下文中一共展示了Mage_Downloadable_Model_Link::getBaseSamplePath方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getLinkData
/**
* Return array of links
*
* @return array
*/
public function getLinkData()
{
$linkArr = array();
$prod = $this->getProduct();
$prodType = $this->getProduct()->getTypeInstance(true);
$links = $this->getProduct()->getTypeInstance(true)->getLinks($this->getProduct());
$priceWebsiteScope = $this->getIsPriceWebsiteScope();
foreach ($links as $item) {
$tmpLinkItem = array('link_id' => $item->getId(), 'title' => $item->getTitle(), 'price' => $this->getCanReadPrice() ? $this->getPriceValue($item->getPrice()) : '', 'number_of_downloads' => $item->getNumberOfDownloads(), 'number_of_purchases' => $item->getNumberOfPurchases(), 'is_shareable' => $item->getIsShareable(), 'link_url' => $item->getLinkUrl(), 'link_type' => $item->getLinkType(), 'sample_file' => $item->getSampleFile(), 'sample_url' => $item->getSampleUrl(), 'sample_type' => $item->getSampleType(), 'sort_order' => $item->getSortOrder());
$file = Mage::helper('downloadable/file')->getFilePath(Mage_Downloadable_Model_Link::getBasePath(), $item->getLinkFile());
if ($item->getLinkFile() && !is_file($file)) {
Mage::helper('core/file_storage_database')->saveFileToFilesystem($file);
}
if ($item->getLinkFile() && is_file($file)) {
$name = '<a href="' . $this->getUrl('*/downloadable_product_edit/link', array('id' => $item->getId(), '_secure' => true)) . '">' . Mage::helper('downloadable/file')->getFileFromPathFile($item->getLinkFile()) . '</a>';
$tmpLinkItem['file_save'] = array(array('file' => $item->getLinkFile(), 'name' => $name, 'size' => filesize($file), 'status' => 'old'));
}
$sampleFile = Mage::helper('downloadable/file')->getFilePath(Mage_Downloadable_Model_Link::getBaseSamplePath(), $item->getSampleFile());
if ($item->getSampleFile() && is_file($sampleFile)) {
$tmpLinkItem['sample_file_save'] = array(array('file' => $item->getSampleFile(), 'name' => Mage::helper('downloadable/file')->getFileFromPathFile($item->getSampleFile()), 'size' => filesize($sampleFile), 'status' => 'old'));
}
if ($item->getNumberOfDownloads() == '0') {
$tmpLinkItem['is_unlimited'] = ' checked="checked"';
}
if ($this->getProduct()->getStoreId() && $item->getStoreTitle()) {
$tmpLinkItem['store_title'] = $item->getStoreTitle();
}
if ($this->getProduct()->getStoreId() && $priceWebsiteScope) {
$tmpLinkItem['website_price'] = $item->getWebsitePrice();
}
$linkArr[] = new Varien_Object($tmpLinkItem);
}
return $linkArr;
}
开发者ID:ankita-parashar,项目名称:magento,代码行数:39,代码来源:ICC_Downloadable_Block_Adminhtml_Catalog_Product_Edit_Tab_Downloadable_Links.php
示例2: 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;
}
示例3: linkSampleAction
/**
* Download link's sample action
*
*/
public function linkSampleAction()
{
$linkId = $this->getRequest()->getParam('link_id', 0);
$link = Mage::getModel('downloadable/link')->load($linkId);
if ($link->getId()) {
$resource = '';
$resourceType = '';
if ($link->getSampleType() == Mage_Downloadable_Helper_Download::LINK_TYPE_URL) {
$resource = $link->getSampleUrl();
$resourceType = Mage_Downloadable_Helper_Download::LINK_TYPE_URL;
} elseif ($link->getSampleType() == Mage_Downloadable_Helper_Download::LINK_TYPE_FILE) {
$resource = Mage::helper('downloadable/file')->getFilePath(Mage_Downloadable_Model_Link::getBaseSamplePath(), $link->getSampleFile());
$resourceType = Mage_Downloadable_Helper_Download::LINK_TYPE_FILE;
}
try {
$this->_processDownload($resource, $resourceType);
exit(0);
} catch (Mage_Core_Exception $e) {
$this->_getCustomerSession()->addError(Mage::helper('downloadable')->__('Sorry, there was an error getting requested content. Please contact store owner.'));
}
}
return $this->_redirectReferer();
}
示例4: items
/**
* Retrieve downloadable product links
*
* @param int|string $productId
* @param string|int $store
* @param string $identifierType ('sku'|'id')
* @return array
*/
public function items($productId, $store = null, $identifierType = null)
{
$product = $this->_getProduct($productId, $store, $identifierType);
$linkArr = array();
$links = $product->getTypeInstance(true)->getLinks($product);
foreach ($links as $item) {
$tmpLinkItem = array('link_id' => $item->getId(), 'title' => $item->getTitle(), 'price' => $item->getPrice(), 'number_of_downloads' => $item->getNumberOfDownloads(), 'is_shareable' => $item->getIsShareable(), 'link_url' => $item->getLinkUrl(), 'link_type' => $item->getLinkType(), 'sample_file' => $item->getSampleFile(), 'sample_url' => $item->getSampleUrl(), 'sample_type' => $item->getSampleType(), 'sort_order' => $item->getSortOrder());
$file = Mage::helper('downloadable/file')->getFilePath(Mage_Downloadable_Model_Link::getBasePath(), $item->getLinkFile());
if ($item->getLinkFile() && !is_file($file)) {
Mage::helper('core/file_storage_database')->saveFileToFilesystem($file);
}
if ($item->getLinkFile() && is_file($file)) {
$name = Mage::helper('downloadable/file')->getFileFromPathFile($item->getLinkFile());
$tmpLinkItem['file_save'] = array(array('file' => $item->getLinkFile(), 'name' => $name, 'size' => filesize($file), 'status' => 'old'));
}
$sampleFile = Mage::helper('downloadable/file')->getFilePath(Mage_Downloadable_Model_Link::getBaseSamplePath(), $item->getSampleFile());
if ($item->getSampleFile() && is_file($sampleFile)) {
$tmpLinkItem['sample_file_save'] = array(array('file' => $item->getSampleFile(), 'name' => Mage::helper('downloadable/file')->getFileFromPathFile($item->getSampleFile()), 'size' => filesize($sampleFile), 'status' => 'old'));
}
if ($item->getNumberOfDownloads() == '0') {
$tmpLinkItem['is_unlimited'] = 1;
}
if ($product->getStoreId() && $item->getStoreTitle()) {
$tmpLinkItem['store_title'] = $item->getStoreTitle();
}
if ($product->getStoreId() && Mage::helper('downloadable')->getIsPriceWebsiteScope()) {
$tmpLinkItem['website_price'] = $item->getWebsitePrice();
}
$linkArr[] = $tmpLinkItem;
}
unset($item);
unset($tmpLinkItem);
unset($links);
$samples = $product->getTypeInstance(true)->getSamples($product)->getData();
return array('links' => $linkArr, 'samples' => $samples);
}
示例5: save
//.........这里部分代码省略.........
$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;
}
}
}
$linkModel->save();
if ($linkModel->getLinkType() == Mage_Downloadable_Helper_Download::LINK_TYPE_FILE && $fileStatusNew) {
try {
Mage::helper('downloadable/file')->moveFileFromTmp(Mage_Downloadable_Model_Link::getBaseTmpPath(), Mage_Downloadable_Model_Link::getBasePath(), $files[0]['file']);
} catch (Exception $e) {
Mage::throwException(Mage::helper('downloadable')->__('An error occurred while saving the file(s).'));
}
}
if ($linkModel->getSampleType() == Mage_Downloadable_Helper_Download::LINK_TYPE_FILE && $sampleFileNew) {
try {
Mage::helper('downloadable/file')->moveFileFromTmp(Mage_Downloadable_Model_Link::getBaseSampleTmpPath(), Mage_Downloadable_Model_Link::getBaseSamplePath(), $sampleFile[0]['file']);
} catch (Exception $e) {
Mage::throwException(Mage::helper('downloadable')->__('An error occurred while saving the file(s).'));
}
}
}
}
if ($_deleteItems) {
Mage::getResourceModel('downloadable/link')->deleteItems($_deleteItems);
}
}
}
return $this;
}
示例6: saveDownLoadProductLink
/**
* Save download product link
*
* @param array $downloadableData
* @param number $downloadProductId
* @param array $linkTpath
* @param array $slinkTpath
*
* @return void
*
*/
public function saveDownLoadProductLink($downloadableData, $downloadProductId, $linkTpath, $slinkTpath, $store)
{
/**
* Storing Downloadable product sample data
*/
foreach ($downloadableData['link'] as $linkItem) {
$linkId = '';
$linkfile = $samplefile = array();
$linkId = $linkItem['link_id'];
$linkfile = $this->assignLinkFile($linkTpath, $linkId, $linkfile);
$samplefile = $this->assignLinkFile($slinkTpath, $linkId, $samplefile);
$linkModel = Mage::getModel('downloadable/link')->setData($linkfile)->setLinkType($linkItem['type'])->setProductId($downloadProductId)->setWebsiteIds(array(Mage::app()->getStore($store)->getWebsiteId()))->setStoreId(0)->setSortOrder($linkItem['sort_order'])->setTitle($linkItem['title'])->setIsShareable($linkItem['is_shareable']);
if ($linkItem['type'] == 'url') {
$linkModel->setLinkUrl($linkItem['link_url']);
}
$linkModel->setPrice($linkItem['price']);
$linkModel->setNumberOfDownloads($linkItem['number_of_downloads']);
if (isset($linkItem['sample']['type'])) {
if ($linkItem['sample']['type'] == 'url') {
$linkModel->setSampleUrl($linkItem['sample']['url']);
}
$linkModel->setSampleType($linkItem['sample']['type']);
}
$sampleFile = '';
$sampleFile = Zend_Json::decode(json_encode($samplefile));
if (!empty($linkTpath[$linkId]) && $linkItem['type'] == 'file') {
$linkFileName = Mage::helper('downloadable/file')->moveFileFromTmp(Mage_Downloadable_Model_Link::getBaseTmpPath(), Mage_Downloadable_Model_Link::getBasePath(), $linkfile);
$linkModel->setLinkFile($linkFileName);
}
if (!empty($slinkTpath[$linkId]) && isset($sampleFile) && ($linkItem['sample']['type'] = 'file')) {
$linkSampleFileName = Mage::helper('downloadable/file')->moveFileFromTmp(Mage_Downloadable_Model_Link::getBaseSampleTmpPath(), Mage_Downloadable_Model_Link::getBaseSamplePath(), $sampleFile);
$linkModel->setSampleFile($linkSampleFileName);
}
Mage::helper('marketplace/marketplace')->saveDownLoadLink($linkModel);
}
}