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


PHP ProductInterface::setDownloadableData方法代码示例

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


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

示例1: saveLink

 /**
  * @param \Magento\Catalog\Api\Data\ProductInterface $product
  * @param LinkInterface $link
  * @param bool $isGlobalScopeContent
  * @return int
  */
 protected function saveLink(\Magento\Catalog\Api\Data\ProductInterface $product, LinkInterface $link, $isGlobalScopeContent)
 {
     $linkData = ['link_id' => $link->getid() === null ? 0 : $link->getid(), 'is_delete' => 0, 'type' => $link->getLinkType(), 'sort_order' => $link->getSortOrder(), 'title' => $link->getTitle(), 'price' => $link->getPrice(), 'number_of_downloads' => $link->getNumberOfDownloads(), 'is_shareable' => $link->getIsShareable()];
     if ($link->getLinkType() == 'file' && $link->getLinkFile() === null) {
         $linkData['file'] = $this->jsonEncoder->encode([$this->fileContentUploader->upload($link->getLinkFileContent(), 'link_file')]);
     } elseif ($link->getLinkType() === 'url') {
         $linkData['link_url'] = $link->getLinkUrl();
     } else {
         //existing link file
         $linkData['file'] = $this->jsonEncoder->encode([['file' => $link->getLinkFile(), 'status' => 'old']]);
     }
     if ($link->getSampleType() == 'file' && $link->getSampleFile() === null) {
         $linkData['sample']['type'] = 'file';
         $linkData['sample']['file'] = $this->jsonEncoder->encode([$this->fileContentUploader->upload($link->getSampleFileContent(), 'link_sample_file')]);
     } elseif ($link->getSampleType() == 'url') {
         $linkData['sample']['type'] = 'url';
         $linkData['sample']['url'] = $link->getSampleUrl();
     }
     $downloadableData = ['link' => [$linkData]];
     $product->setDownloadableData($downloadableData);
     if ($isGlobalScopeContent) {
         $product->setStoreId(0);
     }
     $this->downloadableType->save($product);
     return $product->getLastAddedLinkId();
 }
开发者ID:tingyeeh,项目名称:magento2,代码行数:32,代码来源:LinkRepository.php

示例2: saveSample

 /**
  * @param \Magento\Catalog\Api\Data\ProductInterface $product
  * @param SampleInterface $sample
  * @param bool $isGlobalScopeContent
  * @return int
  */
 protected function saveSample(\Magento\Catalog\Api\Data\ProductInterface $product, SampleInterface $sample, $isGlobalScopeContent)
 {
     $sampleData = ['sample_id' => $sample->getid() === null ? 0 : $sample->getid(), 'is_delete' => 0, 'type' => $sample->getSampleType(), 'sort_order' => $sample->getSortOrder(), 'title' => $sample->getTitle()];
     if ($sample->getSampleType() == 'file' && $sample->getSampleFile() === null) {
         $sampleData['file'] = $this->jsonEncoder->encode([$this->fileContentUploader->upload($sample->getSampleFileContent(), 'sample')]);
     } elseif ($sample->getSampleType() === 'url') {
         $sampleData['sample_url'] = $sample->getSampleUrl();
     } else {
         //existing file
         $sampleData['file'] = $this->jsonEncoder->encode([['file' => $sample->getSampleFile(), 'status' => 'old']]);
     }
     $downloadableData = ['sample' => [$sampleData]];
     $product->setDownloadableData($downloadableData);
     if ($isGlobalScopeContent) {
         $product->setStoreId(0);
     }
     $this->downloadableType->save($product);
     return $product->getLastAddedSampleId();
 }
开发者ID:opexsw,项目名称:magento2,代码行数:25,代码来源:SampleRepository.php


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