23 private $metadataPool;
57 \
Magento\Catalog\Helper\Data $catalogData,
59 \
Magento\Directory\Model\CurrencyFactory $currencyFactory,
63 $this->_catalogData = $catalogData;
65 $this->_currencyFactory = $currencyFactory;
77 $this->
_init(
'downloadable_link',
'link_id');
90 $linkTitleTable = $this->
getTable(
'downloadable_link_title');
91 $linkPriceTable = $this->
getTable(
'downloadable_link_price');
94 $this->
getTable(
'downloadable_link_title')
96 'link_id=:link_id AND store_id=:store_id' 98 $bind = [
':link_id' => $linkObject->getId(),
':store_id' => (int)$linkObject->getStoreId()];
101 $where = [
'link_id = ?' => $linkObject->getId(),
'store_id = ?' => (int)$linkObject->getStoreId()];
102 if ($linkObject->getUseDefaultTitle()) {
105 $insertData = [
'title' => $linkObject->getTitle()];
106 $connection->update($linkTitleTable, $insertData, $where);
109 if (!$linkObject->getUseDefaultTitle()) {
113 'link_id' => $linkObject->getId(),
114 'store_id' => (int)$linkObject->getStoreId(),
115 'title' => $linkObject->getTitle()
121 $select =
$connection->select()->from($linkPriceTable)->where(
'link_id=:link_id AND website_id=:website_id');
122 $bind = [
':link_id' => $linkObject->getId(),
':website_id' => (int)$linkObject->getWebsiteId()];
124 $where = [
'link_id = ?' => $linkObject->getId(),
'website_id = ?' => $linkObject->getWebsiteId()];
125 if ($linkObject->getUseDefaultPrice()) {
128 $connection->update($linkPriceTable, [
'price' => $linkObject->getPrice()], $where);
131 if (!$linkObject->getUseDefaultPrice()) {
133 'link_id' => $linkObject->getId(),
134 'website_id' => (int)$linkObject->getWebsiteId(),
135 'price' => (double)$linkObject->getPrice(),
137 if ($linkObject->getOrigData(
'link_id') != $linkObject->getLinkId()) {
142 if ($linkObject->getWebsiteId() == 0 && $_isNew && !$this->_catalogData->isPriceGlobal()) {
145 $baseCurrency = $this->_configuration->getValue(
146 \
Magento\Directory\Model\Currency::XML_PATH_CURRENCY_BASE,
149 $websiteCurrency = $this->_storeManager->getWebsite(
$websiteId)->getBaseCurrencyCode();
150 if ($websiteCurrency == $baseCurrency) {
157 $newPrice = $linkObject->getPrice() *
$rate;
159 'link_id' => $linkObject->getId(),
161 'price' => $newPrice,
165 $connection->insertMultiple($linkPriceTable, $dataToInsert);
181 $where = [
'link_id = ?' =>
$items->getId()];
183 $where = [
'link_id in (?)' =>
$items];
185 $where = [
'sample_id = ?' =>
$items];
203 $ifNullDefaultTitle =
$connection->getIfNullSql(
'st.title',
's.title');
208 [
's' => $this->
getTable(
'downloadable_link_title')],
209 's.link_id=m.link_id AND s.store_id=0',
212 [
'cpe' => $this->
getTable(
'catalog_product_entity')],
214 'cpe.entity_id = m.product_id',
215 $this->getMetadataPool()->getMetadata(ProductInterface::class)->getLinkField()
219 [
'st' => $this->
getTable(
'downloadable_link_title')],
220 'st.link_id=m.link_id AND st.store_id=:store_id',
221 [
'title' => $ifNullDefaultTitle]
223 'cpe.entity_id=:product_id' 235 return $this->_currencyFactory->create();
242 private function getMetadataPool()
244 if (!$this->metadataPool) {
247 return $this->metadataPool;
getSearchableData($productId, $storeId)
elseif(isset( $params[ 'redirect_parent']))
_init($mainTable, $idFieldName)
__construct(\Magento\Framework\Model\ResourceModel\Db\Context $context, \Magento\Catalog\Helper\Data $catalogData, \Magento\Framework\App\Config\ScopeConfigInterface $configuration, \Magento\Directory\Model\CurrencyFactory $currencyFactory, \Magento\Store\Model\StoreManagerInterface $storeManager, $connectionName=null)
saveItemTitleAndPrice($linkObject)