Example #1
0
 /**
  * Returns whether link checked by default or not
  *
  * @param Link $link
  * @return bool
  * @SuppressWarnings(PHPMD.BooleanGetMethodName)
  */
 public function getIsLinkChecked($link)
 {
     $configValue = $this->getProduct()->getPreconfiguredValues()->getLinks();
     if (!$configValue || !is_array($configValue)) {
         return false;
     }
     return $configValue && in_array($link->getId(), $configValue);
 }
Example #2
0
 /**
  * Delete data by item(s)
  *
  * @param \Magento\Downloadable\Model\Link|array|int $items
  * @return $this
  */
 public function deleteItems($items)
 {
     $connection = $this->getConnection();
     if ($items instanceof \Magento\Downloadable\Model\Link) {
         $where = ['link_id = ?' => $items->getId()];
     } elseif (is_array($items)) {
         $where = ['link_id in (?)' => $items];
     } else {
         $where = ['sample_id = ?' => $items];
     }
     $connection->delete($this->getMainTable(), $where);
     $connection->delete($this->getTable('downloadable_link_title'), $where);
     $connection->delete($this->getTable('downloadable_link_price'), $where);
     return $this;
 }
Example #3
0
 /**
  * Delete data by item(s)
  *
  * @param \Magento\Downloadable\Model\Link|array|int $items
  * @return $this
  */
 public function deleteItems($items)
 {
     $writeAdapter = $this->_getWriteAdapter();
     $where = [];
     if ($items instanceof \Magento\Downloadable\Model\Link) {
         $where = ['link_id = ?' => $items->getId()];
     } elseif (is_array($items)) {
         $where = ['link_id in (?)' => $items];
     } else {
         $where = ['sample_id = ?' => $items];
     }
     if ($where) {
         $writeAdapter->delete($this->getMainTable(), $where);
         $writeAdapter->delete($this->getTable('downloadable_link_title'), $where);
         $writeAdapter->delete($this->getTable('downloadable_link_price'), $where);
     }
     return $this;
 }
Example #4
0
 /**
  * Subroutine for build link
  *
  * @param \Magento\Downloadable\Model\Link $resourceData
  * @param \Magento\Downloadable\Api\Data\LinkInterface $dataObject
  * @return null
  */
 protected function setBasicFields($resourceData, $dataObject)
 {
     $dataObject->setId($resourceData->getId());
     $storeTitle = $resourceData->getStoreTitle();
     $title = $resourceData->getTitle();
     if (!empty($storeTitle)) {
         $dataObject->setTitle($storeTitle);
     } else {
         $dataObject->setTitle($title);
     }
     $dataObject->setSortOrder($resourceData->getSortOrder());
     $dataObject->setSampleType($resourceData->getSampleType());
     $dataObject->setSampleFile($resourceData->getSampleFile());
     $dataObject->setSampleUrl($resourceData->getSampleUrl());
 }
Example #5
0
 /**
  * Subroutine for buildLink and buildSample
  *
  * @param \Magento\Downloadable\Model\Link|\Magento\Downloadable\Model\Sample $resourceData
  * @param Data\DownloadableLinkInfoBuilder|Data\DownloadableSampleInfoBuilder $builder
  * @return null
  */
 protected function setBasicFields($resourceData, $builder)
 {
     $builder->populateWithArray([]);
     $builder->setId($resourceData->getId());
     $storeTitle = $resourceData->getStoreTitle();
     $title = $resourceData->getTitle();
     if (!empty($storeTitle)) {
         $builder->setTitle($storeTitle);
     } else {
         $builder->setTitle($title);
     }
     $builder->setSortOrder($resourceData->getSortOrder());
     $builder->setSampleResource($this->entityInfoGenerator('sample', $resourceData));
 }