本文整理汇总了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);
}
示例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);
}