Skip to content

Commit

Permalink
Merge pull request #12 from Datatrics/1.3.1
Browse files Browse the repository at this point in the history
1.3.1
  • Loading branch information
Marvin-Magmodules authored Mar 25, 2021
2 parents d36ccfe + e6d20f6 commit de1b720
Show file tree
Hide file tree
Showing 33 changed files with 890 additions and 569 deletions.
2 changes: 1 addition & 1 deletion Block/Adminhtml/System/Config/Form/Table/Content.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ private function getContentData(int $storeId): array
$totals = [];
$connection = $this->contentResource->getConnection();
$selectContent = $connection->select()->from(
$connection->getTableName('datatrics_content_store'),
$this->contentResource->getTable('datatrics_content_store'),
'product_id'
)->where('store_id = ?', $storeId);
$totals['items'] = count($connection->fetchAll($selectContent));
Expand Down
2 changes: 1 addition & 1 deletion Block/Adminhtml/System/Config/Form/Table/Profile.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ private function getProfileData(int $storeId): array
$totals = [];
$connection = $this->contentResource->getConnection();
$selectContent = $connection->select()->from(
$connection->getTableName('datatrics_profile'),
$this->contentResource->getTable('datatrics_profile'),
'entity_id'
)->where('store_id = ?', $storeId);
$totals['customers'] = count($connection->fetchAll($selectContent));
Expand Down
2 changes: 1 addition & 1 deletion Block/Adminhtml/System/Config/Form/Table/Sales.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ private function getSalesData(int $storeId): array
$totals = [];
$connection = $this->contentResource->getConnection();
$selectContent = $connection->select()->from(
$connection->getTableName('datatrics_sales'),
$this->contentResource->getTable('datatrics_sales'),
'entity_id'
)->where('store_id = ?', $storeId);
$totals['orders'] = count($connection->fetchAll($selectContent));
Expand Down
2 changes: 1 addition & 1 deletion Controller/Adminhtml/Content/Invalidate.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public function execute()
'store_id = ?' => $storeId
];
$count = $connection->update(
$connection->getTableName('datatrics_content_store'),
$this->contentResource->getTable('datatrics_content_store'),
['status' => 'Queued for Update'],
$where
);
Expand Down
2 changes: 1 addition & 1 deletion Controller/Adminhtml/Content/Update.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public function execute()

$connection = $this->contentResource->getConnection();
$selectProductIds = $connection->select()->from(
$connection->getTableName('datatrics_content_store'),
$this->contentResource->getTable('datatrics_content_store'),
['product_id']
)->where('status = ?', 'Queued for Update')
->where('store_id = ?', $storeId);
Expand Down
2 changes: 1 addition & 1 deletion Model/Command/CategoryUpdate.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public function run(InputInterface $input, OutputInterface $output)
$this->collector->addData('map', ['name'], 'attributeMapper');
$connection = $this->categoryResource->getConnection();
$select = $connection->select()->from(
['eav_attribute' => $connection->getTableName('catalog_category_entity')],
['eav_attribute' => $this->categoryResource->getTable('catalog_category_entity')],
'entity_id'
);
$entityIds = $connection->fetchCol($select, 'entity_id');
Expand Down
14 changes: 7 additions & 7 deletions Model/Command/ContentAdd.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function addProducts($storeId = null, $output = null)
$stores = [];
if (!$storeId) {
$selectStores = $connection->select()->from(
$connection->getTableName('store'),
$this->contentResource->getTable('store'),
'store_id'
);
foreach ($connection->fetchAll($selectStores) as $store) {
Expand All @@ -75,23 +75,23 @@ public function addProducts($storeId = null, $output = null)
$stores[] = $storeId;
}
$selectContent = $connection->select()->from(
$connection->getTableName('datatrics_content'),
$this->contentResource->getTable('datatrics_content'),
'content_id'
);
if ($storeId) {
$selectContent->joinLeft(
['datatrics_content_store' => $connection->getTableName('datatrics_content_store')],
['datatrics_content_store' => $this->contentResource->getTable('datatrics_content_store')],
'content_id = product_id',
[]
)->where('datatrics_content_store.store_id = ?', $storeId);
}

$select = $connection->select()->from(
$connection->getTableName('catalog_product_entity'),
$this->contentResource->getTable('catalog_product_entity'),
'entity_id'
)->joinLeft(
['super_link' => $connection->getTableName('catalog_product_super_link')],
'super_link.product_id =' . $connection->getTableName('catalog_product_entity') . '.entity_id',
['super_link' => $this->contentResource->getTable('catalog_product_super_link')],
'super_link.product_id =' . $this->contentResource->getTable('catalog_product_entity') . '.entity_id',
[
'parent_id' => 'GROUP_CONCAT(parent_id)'
]
Expand Down Expand Up @@ -141,7 +141,7 @@ public function addProducts($storeId = null, $output = null)
}
if ($data) {
$connection->insertArray(
$connection->getTableName('datatrics_content_store'),
$this->contentResource->getTable('datatrics_content_store'),
['product_id', 'store_id', 'status'],
$data
);
Expand Down
4 changes: 2 additions & 2 deletions Model/Command/ContentInvalidate.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function run(InputInterface $input, OutputInterface $output)
$stores = [$storeId];
} else {
$selectStores = $connection->select()->from(
$connection->getTableName('store'),
$this->contentResource->getTable('store'),
'store_id'
);
$stores = [];
Expand All @@ -72,7 +72,7 @@ public function run(InputInterface $input, OutputInterface $output)
$where['product_id IN (?)'] = [$input->getArguments()['product-id']];
}
return $connection->update(
$connection->getTableName('datatrics_content_store'),
$this->contentResource->getTable('datatrics_content_store'),
['status' => 'Queued for Update'],
$where
);
Expand Down
6 changes: 3 additions & 3 deletions Model/Command/ContentUpdate.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ public function run(InputInterface $input, OutputInterface $output)

$connection = $this->contentResource->getConnection();
$select = $connection->select()->from(
$connection->getTableName('datatrics_content_store'),
$this->contentResource->getTable('datatrics_content_store'),
[
'product_id',
'update_attempts'
Expand Down Expand Up @@ -271,7 +271,7 @@ public function prepareData(array $productIds, int $storeId)
];
if ($response['success'] == true) {
$connection->update(
$connection->getTableName('datatrics_content_store'),
$this->contentResource->getTable('datatrics_content_store'),
[
'status' => 'Synced',
'update_msg' => '',
Expand All @@ -281,7 +281,7 @@ public function prepareData(array $productIds, int $storeId)
);
} else {
$connection->update(
$connection->getTableName('datatrics_content_store'),
$this->contentResource->getTable('datatrics_content_store'),
[
'status' => 'Error',
'update_msg' => ''
Expand Down
2 changes: 1 addition & 1 deletion Model/Command/ProfileInvalidate.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function run(InputInterface $input, OutputInterface $output)
$where['customer_id IN (?)'] = [$input->getArguments()['customer-id']];
}
return $connection->update(
$connection->getTableName('datatrics_profile'),
$this->profileResource->getTable('datatrics_profile'),
['status' => 'Queued for Update'],
$where
);
Expand Down
18 changes: 9 additions & 9 deletions Model/Config/System/ContentRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,11 @@ private function configurableProductLogic(int $storeId): string
*
* @param int $storeId
*
* @return bool
* @return string
*/
private function configurableProductUrl(int $storeId): bool
private function configurableProductUrl(int $storeId): string
{
return $this->isSetFlag(self::XML_PATH_CONFIG_USE_PARENT_URL_FOR_SIMPLES, $storeId);
return $this->getStoreValue(self::XML_PATH_CONFIG_USE_PARENT_URL_FOR_SIMPLES, $storeId);
}

/**
Expand Down Expand Up @@ -224,11 +224,11 @@ private function bundleProductLogic(int $storeId): string
*
* @param int $storeId
*
* @return bool
* @return string
*/
private function bundleProductUrl(int $storeId): bool
private function bundleProductUrl(int $storeId): string
{
return $this->isSetFlag(self::XML_PATH_BUNDLE_USE_PARENT_URL_FOR_SIMPLES, $storeId);
return $this->getStoreValue(self::XML_PATH_BUNDLE_USE_PARENT_URL_FOR_SIMPLES, $storeId);
}

/**
Expand Down Expand Up @@ -301,11 +301,11 @@ public function groupedProductLogic(int $storeId): string
*
* @param int $storeId
*
* @return bool
* @return string
*/
public function groupedProductUrl(int $storeId): bool
public function groupedProductUrl(int $storeId): string
{
return $this->isSetFlag(self::XML_PATH_GROUPED_USE_PARENT_URL_FOR_SIMPLES, $storeId);
return $this->getStoreValue(self::XML_PATH_GROUPED_USE_PARENT_URL_FOR_SIMPLES, $storeId);
}

/**
Expand Down
14 changes: 7 additions & 7 deletions Model/Content/Repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ public function prepareContentData(array $productIds)
{
$connection = $this->resource->getConnection();
$selectContent = $connection->select()->from(
$connection->getTableName('datatrics_content_store'),
$this->resource->getTable('datatrics_content_store'),
[
'product_id',
'store_id',
Expand All @@ -225,7 +225,7 @@ public function prepareContentData(array $productIds)
}
// invalidating
$invalidated = $connection->update(
$connection->getTableName('datatrics_content_store'),
$this->resource->getTable('datatrics_content_store'),
['status' => 0],
['product_id in (?)' => $toInvalidate]
);
Expand All @@ -250,19 +250,19 @@ private function addContent($productIds)
{
$connection = $this->resource->getConnection();
$selectStores = $connection->select()->from(
$connection->getTableName('store'),
$this->resource->getTable('store'),
'store_id'
);
$stores = [];
foreach ($connection->fetchAll($selectStores) as $store) {
$stores[] = $store['store_id'];
}
$select = $connection->select()->from(
$connection->getTableName('catalog_product_entity'),
$this->resource->getTable('catalog_product_entity'),
'entity_id'
)->joinLeft(
['super_link' => $connection->getTableName('catalog_product_super_link')],
'super_link.product_id =' . $connection->getTableName('catalog_product_entity') . '.entity_id',
['super_link' => $this->resource->getTable('catalog_product_super_link')],
'super_link.product_id =' . $this->resource->getTable('catalog_product_entity') . '.entity_id',
[
'parent_id' => 'GROUP_CONCAT(parent_id)'
]
Expand All @@ -287,7 +287,7 @@ private function addContent($productIds)
}
if ($data) {
$connection->insertArray(
$connection->getTableName('datatrics_content_store'),
$this->resource->getTable('datatrics_content_store'),
['product_id', 'store_id'],
$data
);
Expand Down
20 changes: 10 additions & 10 deletions Model/Cron/ContentMaintenance.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,22 +84,22 @@ private function collectProductsToDelete()
{
$connection = $this->contentResource->getConnection();
$selectMagentoProducts = $connection->select()->from(
$connection->getTableName('catalog_product_entity'),
$this->contentResource->getTable('catalog_product_entity'),
[
'entity_id'
]
);
$magentoProductIds = $connection->fetchCol($selectMagentoProducts, 'entity_id');
$selectDatatricsProducts = $connection->select()->from(
$connection->getTableName('datatrics_content'),
$this->contentResource->getTable('datatrics_content'),
[
'content_id'
]
);
$datatricsProductIds = $connection->fetchCol($selectDatatricsProducts, 'content_id');
$toDelete = array_diff($datatricsProductIds, $magentoProductIds);
$connection->update(
$connection->getTableName('datatrics_content_store'),
$this->contentResource->getTable('datatrics_content_store'),
['status' => 'Queued for Delete'],
['product_id IN (?)' => $toDelete]
);
Expand All @@ -125,14 +125,14 @@ private function collectProductsToAdd()
{
$connection = $this->contentResource->getConnection();
$selectMagentoProducts = $connection->select()->from(
$connection->getTableName('catalog_product_entity'),
$this->contentResource->getTable('catalog_product_entity'),
[
'entity_id'
]
);
$magentoProductIds = $connection->fetchCol($selectMagentoProducts, 'entity_id');
$selectDatatricsProducts = $connection->select()->from(
$connection->getTableName('catalog_product_entity'),
$this->contentResource->getTable('catalog_product_entity'),
[
'product_id'
]
Expand All @@ -152,19 +152,19 @@ private function addProducts($productIds)
{
$connection = $this->contentResource->getConnection();
$selectStores = $connection->select()->from(
$connection->getTableName('store'),
$this->contentResource->getTable('store'),
'store_id'
);
$stores = [];
foreach ($connection->fetchAll($selectStores) as $store) {
$stores[] = $store['store_id'];
}
$select = $connection->select()->from(
$connection->getTableName('catalog_product_entity'),
$this->contentResource->getTable('catalog_product_entity'),
'entity_id'
)->joinLeft(
['super_link' => $connection->getTableName('catalog_product_super_link')],
'super_link.product_id =' . $connection->getTableName('catalog_product_entity') . '.entity_id',
['super_link' => $this->contentResource->getTable('catalog_product_super_link')],
'super_link.product_id =' . $this->contentResource->getTable('catalog_product_entity') . '.entity_id',
[
'parent_id' => 'GROUP_CONCAT(parent_id)'
]
Expand All @@ -188,7 +188,7 @@ private function addProducts($productIds)
}
if ($data) {
$connection->insertArray(
$connection->getTableName('datatrics_content_store'),
$this->contentResource->getTable('datatrics_content_store'),
['product_id', 'store_id', 'status'],
$data
);
Expand Down
8 changes: 4 additions & 4 deletions Model/Cron/ContentUpdate.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ private function deleteProducts()
{
$connection = $this->contentResource->getConnection();
$select = $connection->select()->from(
$connection->getTableName('datatrics_content_store'),
$this->contentResource->getTable('datatrics_content_store'),
[
'product_id'
]
Expand All @@ -111,11 +111,11 @@ private function deleteProducts()
$where = [
'product_id in (?)' => $productIds
];
$connection->delete($connection->getTableName('datatrics_content_store'), $where);
$connection->delete($this->contentResource->getTable('datatrics_content_store'), $where);
$where = [
'content_id in (?)' => $productIds
];
$connection->delete($connection->getTableName('datatrics_content'), $where);
$connection->delete($this->contentResource->getTable('datatrics_content'), $where);
}

/**
Expand All @@ -142,7 +142,7 @@ private function processStoreData($storeId)
{
$connection = $this->contentResource->getConnection();
$select = $connection->select()->from(
$connection->getTableName('datatrics_content_store'),
$this->contentResource->getTable('datatrics_content_store'),
[
'product_id',
'update_attempts'
Expand Down
Loading

0 comments on commit de1b720

Please sign in to comment.