当前位置: 首页>>代码示例>>PHP>>正文


PHP Mage_Eav_Model_Entity_Collection_Abstract::_joinAttributeToSelect方法代码示例

本文整理汇总了PHP中Mage_Eav_Model_Entity_Collection_Abstract::_joinAttributeToSelect方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Eav_Model_Entity_Collection_Abstract::_joinAttributeToSelect方法的具体用法?PHP Mage_Eav_Model_Entity_Collection_Abstract::_joinAttributeToSelect怎么用?PHP Mage_Eav_Model_Entity_Collection_Abstract::_joinAttributeToSelect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Mage_Eav_Model_Entity_Collection_Abstract的用法示例。


在下文中一共展示了Mage_Eav_Model_Entity_Collection_Abstract::_joinAttributeToSelect方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _joinAttributeToSelect

    /**
     * Adding join statement to collection select instance
     *
     * @param string $method
     * @param object $attribute
     * @param string $tableAlias
     * @param array $condition
     * @param string $fieldCode
     * @param string $fieldAlias
     * @return Mage_Eav_Model_Entity_Collection_Abstract
     */
    protected function _joinAttributeToSelect($method, $attribute, $tableAlias, $condition, $fieldCode, $fieldAlias)
    {
        if (isset($this->_joinAttributes[$fieldCode]['store_id'])) {
            $store_id = $this->_joinAttributes[$fieldCode]['store_id'];
        } else {
            $store_id = $this->getStoreId();
        }

        $adapter = $this->getConnection();

        if ($store_id != $this->getDefaultStoreId() && !$attribute->isScopeGlobal()) {
            /**
             * Add joining default value for not default store
             * if value for store is null - we use default value
             */
            $defCondition = '('.implode(') AND (', $condition).')';
            $defAlias     = $tableAlias . '_default';
            $defAlias     = $this->getConnection()->getTableName($defAlias);
            $defFieldAlias= str_replace($tableAlias, $defAlias, $fieldAlias);
            $tableAlias   = $this->getConnection()->getTableName($tableAlias);

            $defCondition = str_replace($tableAlias, $defAlias, $defCondition);
            $defCondition.= $adapter->quoteInto(
                " AND " . $adapter->quoteColumnAs("$defAlias.store_id", null) . " = ?",
                $this->getDefaultStoreId());

            $this->getSelect()->$method(
                array($defAlias => $attribute->getBackend()->getTable()),
                $defCondition,
                array()
            );

            $method = 'joinLeft';
            $fieldAlias = $this->getConnection()->getCheckSql("{$tableAlias}.value_id > 0",
                $fieldAlias, $defFieldAlias);
            $this->_joinAttributes[$fieldCode]['condition_alias'] = $fieldAlias;
            $this->_joinAttributes[$fieldCode]['attribute']       = $attribute;
        } else {
            $store_id = $this->getDefaultStoreId();
        }
        $condition[] = $adapter->quoteInto(
            $adapter->quoteColumnAs("$tableAlias.store_id", null) . ' = ?', $store_id);
        return parent::_joinAttributeToSelect($method, $attribute, $tableAlias, $condition, $fieldCode, $fieldAlias);
    }
开发者ID:shashankkanungo,项目名称:magento,代码行数:55,代码来源:__catalog.php

示例2: _joinAttributeToSelect

 /**
  * Adding join statement to collection select instance
  *
  * @param   string $method
  * @param   object $attribute
  * @param   string $tableAlias
  * @param   array $condition
  * @param   string $fieldCode
  * @param   string $fieldAlias
  * @return  Mage_Eav_Model_Entity_Collection_Abstract
  */
 protected function _joinAttributeToSelect($method, $attribute, $tableAlias, $condition, $fieldCode, $fieldAlias)
 {
     if (isset($this->_joinAttributes[$fieldCode]['store_id'])) {
         $store_id = $this->_joinAttributes[$fieldCode]['store_id'];
     } else {
         $store_id = $this->getStoreId();
     }
     if ($store_id != $this->getDefaultStoreId() && !$attribute->isScopeGlobal()) {
         /**
          * Add joining default value for not default store
          * if value for store is null - we use default value
          */
         $defCondition = '(' . join(') AND (', $condition) . ')';
         $defAlias = $tableAlias . '_default';
         $defFieldCode = $fieldCode . '_default';
         $defFieldAlias = str_replace($tableAlias, $defAlias, $fieldAlias);
         $defCondition = str_replace($tableAlias, $defAlias, $defCondition);
         $defCondition .= $this->getConnection()->quoteInto(" AND {$defAlias}.store_id=?", $this->getDefaultStoreId());
         $this->getSelect()->{$method}(array($defAlias => $attribute->getBackend()->getTable()), $defCondition, array());
         $method = 'joinLeft';
         $fieldAlias = new Zend_Db_Expr("IF({$tableAlias}.value_id>0, {$fieldAlias}, {$defFieldAlias})");
         $this->_joinAttributes[$fieldCode]['condition_alias'] = $fieldAlias;
         $this->_joinAttributes[$fieldCode]['attribute'] = $attribute;
     } else {
         $store_id = $this->getDefaultStoreId();
     }
     $condition[] = $this->getConnection()->quoteInto("{$tableAlias}.store_id=?", $store_id);
     return parent::_joinAttributeToSelect($method, $attribute, $tableAlias, $condition, $fieldCode, $fieldAlias);
 }
开发者ID:jpbender,项目名称:mage_virtual,代码行数:40,代码来源:Abstract.php


注:本文中的Mage_Eav_Model_Entity_Collection_Abstract::_joinAttributeToSelect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。