/** * @param LoopResultRow $loopResultRow the current result row * @param \Thelia\Model\Product $product * @param $defaultCategoryId * @return mixed */ private function associateValues($loopResultRow, $product, $defaultCategoryId) { $display_initial_price = $product->getVirtualColumn('display_initial_price'); if (is_null($display_initial_price)) { $display_initial_price = 1; } $loopResultRow->set("ID", $product->getId())->set("REF", $product->getRef())->set("IS_TRANSLATED", $product->getVirtualColumn('IS_TRANSLATED'))->set("LOCALE", $this->locale)->set("TITLE", $product->getVirtualColumn('i18n_TITLE'))->set("CHAPO", $product->getVirtualColumn('i18n_CHAPO'))->set("DESCRIPTION", $product->getVirtualColumn('i18n_DESCRIPTION'))->set("POSTSCRIPTUM", $product->getVirtualColumn('i18n_POSTSCRIPTUM'))->set("URL", $this->getReturnUrl() ? $product->getUrl($this->locale) : null)->set("META_TITLE", $product->getVirtualColumn('i18n_META_TITLE'))->set("META_DESCRIPTION", $product->getVirtualColumn('i18n_META_DESCRIPTION'))->set("META_KEYWORDS", $product->getVirtualColumn('i18n_META_KEYWORDS'))->set("POSITION", $product->getVirtualColumn('position_delegate'))->set("VIRTUAL", $product->getVirtual() ? "1" : "0")->set("VISIBLE", $product->getVisible() ? "1" : "0")->set("TEMPLATE", $product->getTemplateId())->set("DEFAULT_CATEGORY", $defaultCategoryId)->set("TAX_RULE_ID", $product->getTaxRuleId())->set("BRAND_ID", $product->getBrandId() ?: 0)->set("SHOW_ORIGINAL_PRICE", $display_initial_price); $this->findNextPrev($loopResultRow, $product, $defaultCategoryId); return $loopResultRow; }
/** * @param LoopResultRow $loopResultRow the current result row * @param \Thelia\Model\Product $product * @param $default_category_id * @return mixed */ private function associateValues($loopResultRow, $product, $default_category_id) { $display_initial_price = $product->getVirtualColumn('display_initial_price'); if (is_null($display_initial_price)) { $display_initial_price = 1; } $loopResultRow->set("ID", $product->getId())->set("REF", $product->getRef())->set("IS_TRANSLATED", $product->getVirtualColumn('IS_TRANSLATED'))->set("LOCALE", $this->locale)->set("TITLE", $product->getVirtualColumn('i18n_TITLE'))->set("CHAPO", $product->getVirtualColumn('i18n_CHAPO'))->set("DESCRIPTION", $product->getVirtualColumn('i18n_DESCRIPTION'))->set("POSTSCRIPTUM", $product->getVirtualColumn('i18n_POSTSCRIPTUM'))->set("URL", $product->getUrl($this->locale))->set("META_TITLE", $product->getVirtualColumn('i18n_META_TITLE'))->set("META_DESCRIPTION", $product->getVirtualColumn('i18n_META_DESCRIPTION'))->set("META_KEYWORDS", $product->getVirtualColumn('i18n_META_KEYWORDS'))->set("POSITION", $product->getPosition())->set("VIRTUAL", $product->getVirtual() ? "1" : "0")->set("VISIBLE", $product->getVisible() ? "1" : "0")->set("TEMPLATE", $product->getTemplateId())->set("DEFAULT_CATEGORY", $default_category_id)->set("TAX_RULE_ID", $product->getTaxRuleId())->set("BRAND_ID", $product->getBrandId() ?: 0)->set("SHOW_ORIGINAL_PRICE", $display_initial_price); if ($this->getBackend_context() || $this->getWithPrevNextInfo()) { $visible = $this->getWithPrevNextVisible(); // Find previous and next category $previousSearch = ProductQuery::create()->joinProductCategory()->where('ProductCategory.category_id = ?', $default_category_id)->filterByPosition($product->getPosition(), Criteria::LESS_THAN)->orderByPosition(Criteria::DESC); if ($visible !== Type\BooleanOrBothType::ANY) { $previousSearch->filterByVisible($visible ? 1 : 0); } $previous = $previousSearch->findOne(); $nextSearch = ProductQuery::create()->joinProductCategory()->where('ProductCategory.category_id = ?', $default_category_id)->filterByPosition($product->getPosition(), Criteria::GREATER_THAN)->orderByPosition(Criteria::ASC); if ($visible !== Type\BooleanOrBothType::ANY) { $nextSearch->filterByVisible($visible ? 1 : 0); } $next = $nextSearch->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); } return $loopResultRow; }
/** * Filter the query by a related \Thelia\Model\Product object * * @param \Thelia\Model\Product|ObjectCollection $product the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * * @return ChildTemplateQuery The current query, for fluid interface */ public function filterByProduct($product, $comparison = null) { if ($product instanceof \Thelia\Model\Product) { return $this->addUsingAlias(TemplateTableMap::ID, $product->getTemplateId(), $comparison); } elseif ($product instanceof ObjectCollection) { return $this->useProductQuery()->filterByPrimaryKeys($product->getPrimaryKeys())->endUse(); } else { throw new PropelException('filterByProduct() only accepts arguments of type \\Thelia\\Model\\Product or Collection'); } }