Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add item_type and item_id to the loop #2

Merged
merged 1 commit into from
Jun 2, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions Loop/TheliaCollectionItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,30 @@
namespace TheliaCollection\Loop;

use Propel\Runtime\ActiveQuery\Criteria;
use Thelia\Core\Template\Element\BaseI18nLoop;
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;
use TheliaCollection\Model\TheliaCollectionItemQuery;
use TheliaCollection\Model\TheliaCollectionQuery;

/**
* Class TheliaCollectionItem.
*
* @method int getId()
* @method int getTheliaCollectionId()
* @method int getId()
* @method string getItemType()
* @method int getItemId()
* @method int getTheliaCollectionId()
*/
class TheliaCollectionItem extends BaseLoop implements PropelSearchLoopInterface
{
protected function getArgDefinitions()
{
return new ArgumentCollection(
Argument::createIntTypeArgument('id'),
Argument::createIntTypeArgument('item_id'),
Argument::createAlphaNumStringTypeArgument('item_type'),
Argument::createIntTypeArgument('thelia_collection_id')
);
}
Expand All @@ -41,6 +43,14 @@ public function buildModelCriteria()
$query->filterByTheliaCollectionId($theliaCollectionId);
}

if (null !== $itemId = $this->getItemId()) {
$query->filterByItemId($itemId);
}

if (null !== $itemType = $this->getItemType()) {
$query->filterByItemType($itemType);
}

$query->orderByPosition(Criteria::ASC);

return $query;
Expand Down