Example #1
0
 /**
  * Get downloadable product samples
  *
  * @param \Magento\Catalog\Model\Product $product
  * @return \Magento\Downloadable\Model\Resource\Sample\Collection
  */
 public function getSamples($product)
 {
     if ($product->getDownloadableSamples() === null) {
         $sampleCollection = $this->_samplesFactory->create()->addProductToFilter($product->getId())->addTitleToResult($product->getStoreId());
         $this->extensionAttributesJoinProcessor->process($sampleCollection);
         $product->setDownloadableSamples($sampleCollection);
     }
     return $product->getDownloadableSamples();
 }
Example #2
0
 /**
  * Get downloadable product samples
  *
  * @param \Magento\Catalog\Model\Product $product
  * @return \Magento\Downloadable\Model\Resource\Sample\Collection
  */
 public function getSamples($product)
 {
     if (is_null($product->getDownloadableSamples())) {
         $_sampleCollection = $this->_samplesFactory->create()->addProductToFilter($product->getId())->addTitleToResult($product->getStoreId());
         $product->setDownloadableSamples($_sampleCollection);
     }
     return $product->getDownloadableSamples();
 }