and product output are now optional

This commit is contained in:
Manuel Raynaud
2014-03-11 15:42:43 +01:00
parent edf6708c2d
commit 33f2b56080
2 changed files with 32 additions and 24 deletions

View File

@@ -83,6 +83,7 @@ class Product extends BaseI18nLoop implements PropelSearchLoopInterface, SearchL
Argument::createIntTypeArgument('min_stock'),
Argument::createFloatTypeArgument('min_weight'),
Argument::createFloatTypeArgument('max_weight'),
Argument::createBooleanTypeArgument('with_prev_next_info', false),
Argument::createBooleanTypeArgument('current'),
Argument::createBooleanTypeArgument('current_category'),
Argument::createIntTypeArgument('depth', 1),
@@ -1004,22 +1005,6 @@ class Product extends BaseI18nLoop implements PropelSearchLoopInterface, SearchL
// Find previous and next product, in the default category.
$default_category_id = $product->getDefaultCategoryId();
$previous = ProductQuery::create()
->joinProductCategory()
->where('ProductCategory.category_id = ?', $default_category_id)
->filterByPosition($product->getPosition(), Criteria::LESS_THAN)
->orderByPosition(Criteria::DESC)
->findOne()
;
$next = ProductQuery::create()
->joinProductCategory()
->where('ProductCategory.category_id = ?', $default_category_id)
->filterByPosition($product->getPosition(), Criteria::GREATER_THAN)
->orderByPosition(Criteria::ASC)
->findOne()
;
$loopResultRow
->set("ID" , $product->getId())
->set("REF" , $product->getRef())
@@ -1041,15 +1026,38 @@ class Product extends BaseI18nLoop implements PropelSearchLoopInterface, SearchL
->set("POSITION" , $product->getPosition())
->set("VISIBLE" , $product->getVisible() ? "1" : "0")
->set("TEMPLATE" , $product->getTemplateId())
->set("HAS_PREVIOUS" , $previous != null ? 1 : 0)
->set("HAS_NEXT" , $next != null ? 1 : 0)
->set("PREVIOUS" , $previous != null ? $previous->getId() : -1)
->set("NEXT" , $next != null ? $next->getId() : -1)
->set("DEFAULT_CATEGORY" , $default_category_id)
->set("TAX_RULE_ID" , $product->getTaxRuleId())
;
if ($this->getBackend_context() || $this->getWithPrevNextInfo()) {
// Find previous and next category
$previous = ProductQuery::create()
->joinProductCategory()
->where('ProductCategory.category_id = ?', $default_category_id)
->filterByPosition($product->getPosition(), Criteria::LESS_THAN)
->orderByPosition(Criteria::DESC)
->findOne()
;
$next = ProductQuery::create()
->joinProductCategory()
->where('ProductCategory.category_id = ?', $default_category_id)
->filterByPosition($product->getPosition(), Criteria::GREATER_THAN)
->orderByPosition(Criteria::ASC)
->findOne()
;
$loopResultRow
->set("HAS_PREVIOUS" , $previous != null ? 1 : 0)
->set("HAS_NEXT" , $next != null ? 1 : 0)
->set("PREVIOUS" , $previous != null ? $previous->getId() : -1)
->set("NEXT" , $next != null ? $next->getId() : -1)
;
}
$loopResult->addRow($loopResultRow);
}