本文整理汇总了PHP中Mage_Eav_Model_Entity_Collection_Abstract::getConnection方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Eav_Model_Entity_Collection_Abstract::getConnection方法的具体用法?PHP Mage_Eav_Model_Entity_Collection_Abstract::getConnection怎么用?PHP Mage_Eav_Model_Entity_Collection_Abstract::getConnection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Eav_Model_Entity_Collection_Abstract
的用法示例。
在下文中一共展示了Mage_Eav_Model_Entity_Collection_Abstract::getConnection方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addValueSortToCollection
/**
* Add Value Sort To Collection Select
*
* @param Mage_Eav_Model_Entity_Collection_Abstract $collection
* @param string $dir direction
* @return Mage_Eav_Model_Entity_Attribute_Source_Abstract
*/
public function addValueSortToCollection($collection, $dir = 'asc')
{
$attributeCode = $this->getAttribute()->getAttributeCode();
$attributeId = $this->getAttribute()->getId();
$attributeTable = $this->getAttribute()->getBackend()->getTable();
if ($this->getAttribute()->isScopeGlobal()) {
$tableName = $attributeCode . '_t';
$collection->getSelect()->joinLeft(array($tableName => $attributeTable), "e.entity_id={$tableName}.entity_id" . " AND {$tableName}.attribute_id='{$attributeId}'" . " AND {$tableName}.store_id='0'", array());
$valueExpr = $tableName . '.value';
} else {
$valueTable1 = $attributeCode . '_t1';
$valueTable2 = $attributeCode . '_t2';
$collection->getSelect()->joinLeft(array($valueTable1 => $attributeTable), "e.entity_id={$valueTable1}.entity_id" . " AND {$valueTable1}.attribute_id='{$attributeId}'" . " AND {$valueTable1}.store_id='0'", array())->joinLeft(array($valueTable2 => $attributeTable), "e.entity_id={$valueTable2}.entity_id" . " AND {$valueTable2}.attribute_id='{$attributeId}'" . " AND {$valueTable2}.store_id='{$collection->getStoreId()}'", array());
$valueExpr = $collection->getConnection()->getCheckSql($valueTable2 . '.value_id > 0', $valueTable2 . '.value', $valueTable1 . '.value');
}
$collection->getSelect()->order($valueExpr . ' ' . $dir);
return $this;
}
示例2: joinTableToEavCollection
/**
* Join url rewrite table to eav collection
*
* @param Mage_Eav_Model_Entity_Collection_Abstract $collection
* @param int $storeId
* @return Enterprise_Catalog_Helper_Category_UrlRewrite
*/
public function joinTableToEavCollection(Mage_Eav_Model_Entity_Collection_Abstract $collection, $storeId)
{
$requestPath = $this->_connection->getIfNullSql('url_rewrite.request_path', 'default_ur.request_path');
$collection->getSelect()->joinLeft(array('url_rewrite_category' => $collection->getTable('enterprise_catalog/category')), 'url_rewrite_category.category_id = e.entity_id' . ' AND ' . $collection->getConnection()->quoteInto('url_rewrite_category.store_id = ?', $storeId), array(''))->joinLeft(array('url_rewrite' => $collection->getTable('enterprise_urlrewrite/url_rewrite')), 'url_rewrite_category.url_rewrite_id = url_rewrite.url_rewrite_id AND url_rewrite.is_system = 1', array(''))->joinLeft(array('default_urc' => $collection->getTable('enterprise_catalog/category')), 'default_urc.category_id = e.entity_id AND default_urc.store_id = 0', array(''))->joinLeft(array('default_ur' => $collection->getTable('enterprise_urlrewrite/url_rewrite')), 'default_ur.url_rewrite_id = default_urc.url_rewrite_id AND default_ur.is_system = 1', array('request_path' => $requestPath));
return $this;
}