-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: pseventbus v4 order cart rules (#347)
- Loading branch information
Showing
26 changed files
with
339 additions
and
139 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
services: | ||
PrestaShop\Module\PsEventbus\Repository\NewRepository\OrderRepository: | ||
class: PrestaShop\Module\PsEventbus\Repository\NewRepository\OrderRepository | ||
public: true | ||
|
||
PrestaShop\Module\PsEventbus\Repository\NewRepository\OrderCartRuleRepository: | ||
class: PrestaShop\Module\PsEventbus\Repository\NewRepository\OrderCartRuleRepository | ||
public: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
.../NewRepositoryTemp/AbstractRepository.php → ...tory/NewRepository/AbstractRepository.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
<?php | ||
|
||
namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; | ||
|
||
class OrderCartRuleRepository extends AbstractRepository implements RepositoryInterface | ||
{ | ||
const TABLE_NAME = 'order_cart_rule'; | ||
|
||
/** | ||
* @return mixed | ||
* | ||
* @throws \PrestaShopException | ||
*/ | ||
public function generateBaseQuery() | ||
{ | ||
$this->query = new \DbQuery(); | ||
|
||
$this->query->from(self::TABLE_NAME, 'ocr'); | ||
|
||
$this->query->select('ocr.id_order_cart_rule'); | ||
$this->query->select('ocr.id_order'); | ||
$this->query->select('ocr.id_cart_rule'); | ||
$this->query->select('ocr.id_order_invoice'); | ||
$this->query->select('ocr.name'); | ||
$this->query->select('ocr.value'); | ||
$this->query->select('ocr.value_tax_excl'); | ||
$this->query->select('ocr.free_shipping'); | ||
|
||
if (defined('_PS_VERSION_') && version_compare(_PS_VERSION_, '1.7.7.0', '>=')) { | ||
$this->query->select('ocr.deleted'); | ||
} | ||
} | ||
|
||
/** | ||
* @param int $offset | ||
* @param int $limit | ||
* @param string $langIso | ||
* @param bool $debug | ||
* | ||
* @return array<mixed> | ||
* | ||
* @throws \PrestaShopException | ||
* @throws \PrestaShopDatabaseException | ||
*/ | ||
public function getContentsForFull($offset, $limit, $langIso, $debug) | ||
{ | ||
$this->generateBaseQuery(); | ||
|
||
$this->query->limit((int) $limit, (int) $offset); | ||
|
||
return $this->runQuery($debug); | ||
} | ||
|
||
/** | ||
* @param int $limit | ||
* @param array<mixed> $contentIds | ||
* @param string $langIso | ||
* @param bool $debug | ||
* | ||
* @return array<mixed> | ||
* | ||
* @throws \PrestaShopException | ||
* @throws \PrestaShopDatabaseException | ||
*/ | ||
public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) | ||
{ | ||
$this->generateBaseQuery(); | ||
|
||
$this->query->where('ocr.id_order IN(' . implode(',', array_map('intval', $contentIds)) . ')') | ||
->limit($limit); | ||
|
||
return $this->runQuery($debug); | ||
} | ||
|
||
/** | ||
* @param int $offset | ||
* @param string $langIso | ||
* @param bool $debug | ||
* | ||
* @return int | ||
* | ||
* @throws \PrestaShopException | ||
* @throws \PrestaShopDatabaseException | ||
*/ | ||
public function countFullSyncContentLeft($offset, $langIso, $debug) | ||
{ | ||
$result = $this->getContentsForFull($offset, 1, $langIso, $debug); | ||
|
||
if (!is_array($result) || empty($result)) { | ||
return 0; | ||
} | ||
|
||
return count($result); | ||
} | ||
} |
Oops, something went wrong.