public function buildDataSet(Lang $lang)
 {
     /** @var \Thelia\Model\AttributeCombinationQuery $query */
     $query = parent::buildDataSet($lang);
     $pseJoin = new Join(AttributeCombinationTableMap::PRODUCT_SALE_ELEMENTS_ID, ProductSaleElementsTableMap::ID);
     $pseJoin->setRightTableAlias("pse_tax_join");
     $productJoin = new Join(ProductSaleElementsTableMap::ID, ProductTableMap::ID);
     $productJoin->setRightTableAlias("product_tax_join");
     $taxJoin = new Join("`product_tax_join`.TAX_RULE_ID", TaxRuleTableMap::ID, Criteria::LEFT_JOIN);
     $taxI18nJoin = new Join(TaxRuleTableMap::ID, TaxRuleI18nTableMap::ID, Criteria::LEFT_JOIN);
     $query->addJoinObject($pseJoin, "pse_tax_join")->addJoinObject($productJoin, "product_tax_join")->addJoinObject($productJoin)->addJoinObject($taxJoin)->addJoinObject($taxI18nJoin)->addAsColumn("product_TAX_TITLE", TaxRuleI18nTableMap::TITLE)->addAsColumn("tax_ID", TaxRuleTableMap::ID)->select($query->getSelect() + ["product_TAX_TITLE", "tax_ID"]);
     I18n::addI18nCondition($query, TaxRuleI18nTableMap::TABLE_NAME, TaxRuleTableMap::ID, TaxRuleI18nTableMap::ID, TaxRuleI18nTableMap::LOCALE, $lang->getLocale());
     $dataSet = $query->keepQuery(true)->find()->toArray();
     $productSaleElements = ProductSaleElementsQuery::create()->find()->toKeyIndex("Id");
     $currencies = CurrencyQuery::create()->find()->toKeyIndex("Code");
     foreach ($dataSet as &$line) {
         /** @var \Thelia\Model\ProductSaleElements $pse */
         $pse = $productSaleElements[$line["product_sale_elements_ID"]];
         $pricesTools = $pse->getPricesByCurrency($currencies[$line["currency_CODE"]]);
         $line["price_PRICE"] = $pricesTools->getPrice();
         $line["price_PROMO_PRICE"] = $pricesTools->getPromoPrice();
     }
     return $dataSet;
 }
Ejemplo n.º 2
0
 /**
  * Add a join with multiple conditions
  * @deprecated use Join::setJoinCondition($criterion) instead
  *
  * @see http://propel.phpdb.org/trac/ticket/167, http://propel.phpdb.org/trac/ticket/606
  *
  * Example usage:
  * $c->addMultipleJoin(array(
  *     array(LeftTableMap::LEFT_COLUMN, RightTableMap::RIGHT_COLUMN),  // if no third argument, defaults to Criteria::EQUAL
  *     array(FoldersTableMap::alias( 'fo', FoldersTableMap::LFT ), FoldersTableMap::alias( 'parent', FoldersTableMap::RGT ), Criteria::LESS_EQUAL )
  *   ),
  *   Criteria::LEFT_JOIN
  * );
  *
  * @see addJoin()
  * @param array  $conditions An array of conditions, each condition being an array (left, right, operator)
  * @param string $joinType   A String with the join operator. Defaults to an implicit join.
  *
  * @return $this|Criteria A modified Criteria object.
  */
 public function addMultipleJoin($conditions, $joinType = null)
 {
     $join = new Join();
     $join->setIdentifierQuoting($this->isIdentifierQuotingEnabled());
     $joinCondition = null;
     foreach ($conditions as $condition) {
         $left = $condition[0];
         $right = $condition[1];
         $pos = strrpos($left, '.');
         if ($pos) {
             $leftTableAlias = substr($left, 0, $pos);
             $leftColumnName = substr($left, $pos + 1);
             list($leftTableName, $leftTableAlias) = $this->getTableNameAndAlias($leftTableAlias);
         } else {
             list($leftTableName, $leftTableAlias) = [null, null];
             $leftColumnName = $left;
         }
         $pos = strrpos($right, '.');
         if ($pos) {
             $rightTableAlias = substr($right, 0, $pos);
             $rightColumnName = substr($right, $pos + 1);
             list($rightTableName, $rightTableAlias) = $this->getTableNameAndAlias($rightTableAlias);
         } else {
             list($rightTableName, $rightTableAlias) = [null, null];
             $rightColumnName = $right;
         }
         if (!$join->getRightTableName()) {
             $join->setRightTableName($rightTableName);
         }
         if (!$join->getRightTableAlias()) {
             $join->setRightTableAlias($rightTableAlias);
         }
         $conditionClause = $leftTableAlias ? $leftTableAlias . '.' : ($leftTableName ? $leftTableName . '.' : '');
         $conditionClause .= $leftColumnName;
         $conditionClause .= isset($condition[2]) ? $condition[2] : Join::EQUAL;
         $conditionClause .= $rightTableAlias ? $rightTableAlias . '.' : ($rightTableName ? $rightTableName . '.' : '');
         $conditionClause .= $rightColumnName;
         $criterion = $this->getNewCriterion($leftTableName . '.' . $leftColumnName, $conditionClause, Criteria::CUSTOM);
         if (null === $joinCondition) {
             $joinCondition = $criterion;
         } else {
             $joinCondition = $joinCondition->addAnd($criterion);
         }
     }
     $join->setJoinType($joinType);
     $join->setJoinCondition($joinCondition);
     return $this->addJoinObject($join);
 }