-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28 from logeecom/3.0-3.4
Release version 0.1.7
- Loading branch information
Showing
20 changed files
with
706 additions
and
11 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
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
79 changes: 79 additions & 0 deletions
79
system/classes/external/mollie/Components/Entity/Repository/GambioOrderProductRepository.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
<?php | ||
|
||
|
||
namespace Mollie\Gambio\Entity\Repository; | ||
|
||
/** | ||
* Class GambioOrderProductRepository | ||
* | ||
* @package Mollie\Gambio\Entity\Repository | ||
*/ | ||
class GambioOrderProductRepository extends GambioBaseRepository | ||
{ | ||
/** | ||
* Returns list of orders products filtered by order id with following details | ||
* - orders_products_id | ||
* - products_id | ||
* - products_quantity | ||
* - products_properties_combis_id | ||
* - products_attributes_filename | ||
* - date_purchased | ||
* | ||
* @param string $orderId | ||
* | ||
* @return array | ||
*/ | ||
public function getOrderProductsWithAttributes($orderId) | ||
{ | ||
return $this->queryBuilder->query($this->getOrderProductsWithDetailsQuery($orderId))->result_array(); | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
* @return string | ||
*/ | ||
protected function _getTableName() | ||
{ | ||
return TABLE_ORDERS_PRODUCTS; | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
* @return string | ||
*/ | ||
protected function _getIdentifierKey() | ||
{ | ||
return 'orders_products_id'; | ||
} | ||
|
||
/** | ||
* @param string $orderId | ||
* | ||
* @return string | ||
*/ | ||
private function getOrderProductsWithDetailsQuery($orderId) | ||
{ | ||
return 'SELECT DISTINCT | ||
op.orders_products_id, | ||
op.products_id, | ||
op.products_quantity, | ||
opp.products_properties_combis_id, | ||
pad.products_attributes_filename, | ||
o.date_purchased | ||
FROM ' . TABLE_ORDERS_PRODUCTS . ' op | ||
LEFT JOIN ' . TABLE_ORDERS . ' o | ||
ON op.orders_id = o.orders_id | ||
LEFT JOIN orders_products_properties opp | ||
ON opp.orders_products_id = op.orders_products_id | ||
LEFT JOIN ' . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . ' `opa` | ||
ON opa.orders_products_id = op.orders_products_id | ||
LEFT JOIN ' . TABLE_PRODUCTS_ATTRIBUTES . ' pa | ||
ON op.products_id = pa.products_id | ||
AND opa.options_id = pa.options_id | ||
AND opa.options_values_id = pa.options_values_id | ||
LEFT JOIN ' . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " pad | ||
ON pa.products_attributes_id=pad.products_attributes_id | ||
WHERE | ||
op.orders_id = '" . xtc_db_input($orderId) . "'"; | ||
} | ||
} |
88 changes: 88 additions & 0 deletions
88
...lasses/external/mollie/Components/Entity/Repository/GambioProductAttributesRepository.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
<?php | ||
|
||
|
||
namespace Mollie\Gambio\Entity\Repository; | ||
|
||
/** | ||
* Class GambioProductPropertiesRepository | ||
* | ||
* @package Mollie\Gambio\Entity\Repository | ||
*/ | ||
class GambioProductAttributesRepository extends GambioBaseRepository | ||
{ | ||
/** | ||
* Returns product attributes list filtered by order id and order product id in format: | ||
* - products_options | ||
* - products_options_values | ||
* | ||
* @param int $orderId | ||
* @param int $ordersProductsId | ||
* | ||
* @return array | ||
*/ | ||
public function getOrdersAttributes($orderId, $ordersProductsId) | ||
{ | ||
return $this->queryBuilder | ||
->select('products_options, products_options_values') | ||
->where('orders_id', $orderId, true) | ||
->where('orders_products_id', $ordersProductsId, true) | ||
->get($this->_getTableName()) | ||
->result('array'); | ||
} | ||
|
||
/** | ||
* @param int $productsId | ||
* @param string $productsOptions | ||
* @param string $productsOptionsValues | ||
* | ||
* @return mixed | ||
*/ | ||
public function getProductAttributesId($productsId, $productsOptions, $productsOptionsValues) | ||
{ | ||
$query = "SELECT pa.products_attributes_id | ||
FROM products_options_values pov, | ||
products_options po, | ||
products_attributes pa | ||
WHERE po.products_options_name = '" . addslashes($productsOptions) . "' | ||
AND po.products_options_id = pa.options_id | ||
AND pov.products_options_values_id = pa.options_values_id | ||
AND pov.products_options_values_name = '" . addslashes($productsOptionsValues) . "' | ||
AND pa.products_id = '" . $productsId . "' | ||
LIMIT 1"; | ||
|
||
$result = $this->queryBuilder->query($query)->result_array(); | ||
|
||
return !empty($result[0]['products_attributes_id']) ? $result[0]['products_attributes_id'] : null; | ||
} | ||
|
||
/** | ||
* Increases attributes stock | ||
* | ||
* @param int $productAttributesId | ||
* @param int $quantity | ||
*/ | ||
public function increaseAttributesStock($productAttributesId, $quantity) | ||
{ | ||
$query = 'UPDATE products_attributes | ||
SET attributes_stock = attributes_stock + ' . (int)$quantity . " | ||
WHERE products_attributes_id = '" . (int)$productAttributesId . "'"; | ||
|
||
$this->queryBuilder->query($query); | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
protected function _getTableName() | ||
{ | ||
return TABLE_ORDERS_PRODUCTS_ATTRIBUTES; | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
protected function _getIdentifierKey() | ||
{ | ||
return 'products_attributes_id'; | ||
} | ||
} |
73 changes: 73 additions & 0 deletions
73
.../external/mollie/Components/Entity/Repository/GambioProductPropertiesCombisRepository.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<?php | ||
|
||
|
||
namespace Mollie\Gambio\Entity\Repository; | ||
|
||
/** | ||
* Class ProductPropertiesCombisRepository | ||
* | ||
* @package Mollie\Gambio\Entity\Repository | ||
*/ | ||
class GambioProductPropertiesCombisRepository extends GambioBaseRepository | ||
{ | ||
|
||
/** | ||
* Returns row count specified by productId | ||
* | ||
* @param int $productId | ||
* | ||
* @return int | ||
*/ | ||
public function countByProductId($productId) | ||
{ | ||
return $this->queryBuilder | ||
->select('products_properties_combis_id') | ||
->from($this->_getTableName()) | ||
->where('products_id', $productId) | ||
->get() | ||
->num_rows(); | ||
} | ||
|
||
/** | ||
* Increases combi quantity by productId | ||
* | ||
* @param int $productId | ||
* @param int $productsPropertiesCombisId | ||
* @param int $quantity | ||
*/ | ||
public function increaseCombiQuantity($productId, $productsPropertiesCombisId, $quantity) | ||
{ | ||
$this->queryBuilder->query($this->getUpdateProductPropertiesCombiesQuery($productId, $productsPropertiesCombisId, $quantity)); | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
protected function _getTableName() | ||
{ | ||
return 'products_properties_combis'; | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
protected function _getIdentifierKey() | ||
{ | ||
return 'products_properties_combis_values_id'; | ||
} | ||
|
||
/** | ||
* @param int $productId | ||
* @param int $productsPropertiesCombisId | ||
* @param int $quantity | ||
* | ||
* @return string | ||
*/ | ||
private function getUpdateProductPropertiesCombiesQuery($productId, $productsPropertiesCombisId, $quantity) | ||
{ | ||
return 'UPDATE ' . $this->_getTableName() . ' | ||
SET combi_quantity = combi_quantity + ' . (int)$quantity . " | ||
WHERE products_properties_combis_id = '" . (int)$productsPropertiesCombisId . "' | ||
AND products_id = '" . (int)$productId . "'"; | ||
} | ||
} |
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
Oops, something went wrong.