-
Notifications
You must be signed in to change notification settings - Fork 3
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 #2 from ThomasDaSilva/main
Update Read.me & Fix module & Add a Product Review Loop
- Loading branch information
Showing
8 changed files
with
120 additions
and
25 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<?php | ||
|
||
namespace GuaranteedOpinion\Loop; | ||
|
||
use GuaranteedOpinion\Model\GuaranteedOpinionProductReviewQuery; | ||
use Propel\Runtime\ActiveQuery\Criteria; | ||
use Propel\Runtime\ActiveQuery\ModelCriteria; | ||
use Thelia\Core\Template\Element\BaseLoop; | ||
use Thelia\Core\Template\Element\LoopResult; | ||
use Thelia\Core\Template\Element\LoopResultRow; | ||
use Thelia\Core\Template\Element\PropelSearchLoopInterface; | ||
use Thelia\Core\Template\Loop\Argument\Argument; | ||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection; | ||
|
||
/** | ||
* @method getMinRate() | ||
* @method getProduct() | ||
*/ | ||
class GuaranteedProductLoop extends BaseLoop implements PropelSearchLoopInterface | ||
{ | ||
|
||
public function parseResults(LoopResult $loopResult): LoopResult | ||
{ | ||
foreach ($loopResult->getResultDataCollection() as $review) { | ||
$loopResultRow = new LoopResultRow($review); | ||
|
||
$loopResultRow | ||
->set('ID', $review->getId()) | ||
->set('PRODUCT_REVIEW_ID', $review->getProductReviewId()) | ||
->set('NAME', $review->getName()) | ||
->set('RATE', $review->getRate()) | ||
->set('REVIEW', $review->getReview()) | ||
->set('REVIEW_DATE', $review->getReviewDate()?->format('Y-m-d')) | ||
->set('PRODUCT_ID', $review->getProductId()) | ||
->set('ORDER_ID', $review->getOrderId()) | ||
->set('ORDER_DATE', $review->getOrderDate()?->format('Y-m-d')) | ||
->set('REPLY', $review->getReply()) | ||
->set('REPLY_DATE', $review->getReplyDate()?->format('Y-m-d')) | ||
; | ||
$this->addOutputFields($loopResultRow, $review); | ||
|
||
$loopResult->addRow($loopResultRow); | ||
} | ||
|
||
return $loopResult; | ||
} | ||
|
||
public function buildModelCriteria(): GuaranteedOpinionProductReviewQuery|ModelCriteria | ||
{ | ||
$search = GuaranteedOpinionProductReviewQuery::create(); | ||
|
||
if (null !== $productId = $this->getProduct()) { | ||
$search->filterByProductId($productId, Criteria::IN); | ||
} | ||
|
||
if (null !== $minRate = $this->getMinRate()) { | ||
$search->filterByRate($minRate, Criteria::GREATER_EQUAL); | ||
} | ||
|
||
return $search; | ||
} | ||
|
||
protected function getArgDefinitions(): ArgumentCollection | ||
{ | ||
return new ArgumentCollection( | ||
Argument::createIntListTypeArgument('product'), | ||
Argument::createIntListTypeArgument('min_rate') | ||
); | ||
} | ||
} |
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