Skip to content

Commit

Permalink
Merge pull request #177 from leemyongpakvn/migrate-from-objectmodel-t…
Browse files Browse the repository at this point in the history
…o-doctrinedbal-final

Migrate from ObjectModel to Doctrine (final)
  • Loading branch information
M0rgan01 authored Aug 23, 2023
2 parents a86b94e + 8ebec5e commit 43c6fb1
Show file tree
Hide file tree
Showing 10 changed files with 728 additions and 105 deletions.
19 changes: 19 additions & 0 deletions ProductComment.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,9 @@ public static function getRatings($id_product)
return Db::getInstance((bool) _PS_USE_SQL_SLAVE_)->getRow($sql);
}

/**
* @deprecated 4.0.0
*/
public static function getAverageGrade($id_product)
{
$validate = Configuration::get('PRODUCT_COMMENTS_MODERATE');
Expand Down Expand Up @@ -235,6 +238,8 @@ public static function getAveragesByProduct($id_product, $id_lang)
* Return number of comments and average grade by products
*
* @return int|false
*
* @deprecated 4.0.0
*/
public static function getCommentNumber($id_product)
{
Expand Down Expand Up @@ -279,6 +284,8 @@ public static function getGradedCommentNumber($id_product)
* Get comments by Validation
*
* @return array Comments
*
* @deprecated 6.0.0
*/
public static function getByValidate($validate = '0', $deleted = false, $p = null, $limit = null, $skip_validate = false)
{
Expand Down Expand Up @@ -306,6 +313,8 @@ public static function getByValidate($validate = '0', $deleted = false, $p = nul
* Get numbers of comments by Validation
*
* @return int Count of comments
*
* @deprecated 6.0.0
*/
public static function getCountByValidate($validate = '0', $skip_validate = false)
{
Expand Down Expand Up @@ -360,6 +369,8 @@ public function validate($validate = '1')
* Delete a comment, grade and report data
*
* @return bool succeed
*
* @deprecated 6.0.0
*/
public function delete()
{
Expand All @@ -373,6 +384,8 @@ public function delete()
* Delete Grades
*
* @return bool succeed
*
* @deprecated 6.0.0
*/
public static function deleteGrades($id_product_comment)
{
Expand All @@ -389,6 +402,8 @@ public static function deleteGrades($id_product_comment)
* Delete Reports
*
* @return bool succeed
*
* @deprecated 6.0.0
*/
public static function deleteReports($id_product_comment)
{
Expand All @@ -405,6 +420,8 @@ public static function deleteReports($id_product_comment)
* Delete usefulness
*
* @return bool succeed
*
* @deprecated 6.0.0
*/
public static function deleteUsefulness($id_product_comment)
{
Expand Down Expand Up @@ -473,6 +490,8 @@ public static function isAlreadyUsefulness($id_product_comment, $id_customer)
* Get reported comments
*
* @return array Comments
*
* @deprecated 6.0.0
*/
public static function getReportedComments()
{
Expand Down
21 changes: 21 additions & 0 deletions ProductCommentCriterion.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ public function addCategory($id_category)
* Add grade to a criterion
*
* @return bool succeed
*
* @deprecated 4.0.0
*/
public function addGrade($id_product_comment, $grade)
{
Expand All @@ -154,6 +156,8 @@ public function addGrade($id_product_comment, $grade)
* Get criterion by Product
*
* @return array Criterion
*
* @deprecated 4.0.0
*/
public static function getByProduct($id_product, $id_lang)
{
Expand Down Expand Up @@ -201,6 +205,8 @@ public static function getByProduct($id_product, $id_lang)
* Get Criterions
*
* @return array Criterions
*
* @deprecated 6.0.0
*/
public static function getCriterions($id_lang, $type = false, $active = false)
{
Expand All @@ -224,6 +230,9 @@ public static function getCriterions($id_lang, $type = false, $active = false)
return $criterions;
}

/**
* @deprecated 6.0.0
*/
public function getProducts()
{
$res = Db::getInstance()->executeS('
Expand All @@ -240,6 +249,9 @@ public function getProducts()
return $products;
}

/**
* @deprecated 6.0.0
*/
public function getCategories()
{
$res = Db::getInstance()->executeS('
Expand All @@ -256,20 +268,29 @@ public function getCategories()
return $criterions;
}

/**
* @deprecated 6.0.0
*/
public function deleteCategories()
{
return Db::getInstance()->execute('
DELETE FROM `' . _DB_PREFIX_ . 'product_comment_criterion_category`
WHERE `id_product_comment_criterion` = ' . (int) $this->id);
}

/**
* @deprecated 6.0.0
*/
public function deleteProducts()
{
return Db::getInstance()->execute('
DELETE FROM `' . _DB_PREFIX_ . 'product_comment_criterion_product`
WHERE `id_product_comment_criterion` = ' . (int) $this->id);
}

/**
* @deprecated 6.0.0
*/
public static function getTypes()
{
// Instance of module class for translations
Expand Down
2 changes: 2 additions & 0 deletions config/common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ services:
product_comment_criterion_repository:
class: PrestaShop\Module\ProductComment\Repository\ProductCommentCriterionRepository
arguments:
- '@doctrine'
- '@doctrine.dbal.default_connection'
- '%database_prefix%'

product_comment_repository:
class: PrestaShop\Module\ProductComment\Repository\ProductCommentRepository
arguments:
- '@doctrine'
- '@doctrine.dbal.default_connection'
- '%database_prefix%'
- '@=service("prestashop.adapter.legacy.configuration").get("PRODUCT_COMMENTS_ALLOW_GUESTS")'
Expand Down
Loading

0 comments on commit 43c6fb1

Please sign in to comment.