本文整理匯總了PHP中Varien_Data_Collection::getSelect方法的典型用法代碼示例。如果您正苦於以下問題:PHP Varien_Data_Collection::getSelect方法的具體用法?PHP Varien_Data_Collection::getSelect怎麽用?PHP Varien_Data_Collection::getSelect使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Varien_Data_Collection
的用法示例。
在下文中一共展示了Varien_Data_Collection::getSelect方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: setCollection
/**
* set collection object
*
* @param Varien_Data_Collection $collection
*/
public function setCollection($collection)
{
if (Mage::helper('catalog')->isModuleEnabled('Mage_CatalogInventory')) {
$select = $collection->getSelect();
$fromParts = $select->getPart(Zend_Db_Select::FROM);
if (isset($fromParts['at_qty'])) {
unset($fromParts['at_qty']);
$select->reset(Zend_Db_Select::FROM);
$select->setPart(Zend_Db_Select::FROM, $fromParts);
$subquery = $collection->getConnection()->select()->from(array('at_sub_qty' => $collection->getResource()->getTable('cataloginventory/stock_item')), array('product_id'))->columns(new Zend_Db_Expr("SUM(at_sub_qty.qty) AS qty"))->group('at_sub_qty.product_id');
$select->joinLeft(array('at_qty' => $subquery), 'at_qty.product_id=e.entity_id', array());
}
}
parent::setCollection($collection);
}