本文整理汇总了PHP中Varien_Data_Collection_Db::getResource方法的典型用法代码示例。如果您正苦于以下问题:PHP Varien_Data_Collection_Db::getResource方法的具体用法?PHP Varien_Data_Collection_Db::getResource怎么用?PHP Varien_Data_Collection_Db::getResource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Varien_Data_Collection_Db
的用法示例。
在下文中一共展示了Varien_Data_Collection_Db::getResource方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: applyLogToCollection
/**
* Add events log to a collection
* The collection id field is used without corellation, so it must be unique.
* DESC ordering by event will be added to the collection
*
* @param Varien_Data_Collection_Db $collection
* @param int $eventTypeId
* @param int $eventSubjectId
* @param int $subtype
* @param array $skipIds
*/
public function applyLogToCollection(Varien_Data_Collection_Db $collection, $eventTypeId, $eventSubjectId, $subtype, $skipIds = array())
{
$idFieldName = $collection->getResource()->getIdFieldName();
$derivedSelect = $this->getReadConnection()->select()->from($this->getTable('reports/event'), array('event_id' => new Zend_Db_Expr('MAX(event_id)'), 'object_id'))->where('event_type_id=?', (int) $eventTypeId)->where('subject_id=?', (int) $eventSubjectId)->where('subtype=?', (int) $subtype)->where('store_id IN(?)', $this->getCurrentStoreIds())->group('object_id');
if ($skipIds) {
if (!is_array($skipIds)) {
$skipIds = array((int) $skipIds);
}
$derivedSelect->where('object_id NOT IN(?)', $skipIds);
}
$collection->getSelect()->joinInner(array('evt' => new Zend_Db_Expr("({$derivedSelect})")), "`{$idFieldName}`=evt.object_id", array())->order('evt.event_id DESC');
}
示例2: addGroupsCatalogFilterToCollection
/**
* Inner join the groupscatalog index table to hide entities not visible to the specified customer group id
*
* @param Varien_Data_Collection_Db $collection
* @param int $groupId The customer group id
* @return void
*/
public function addGroupsCatalogFilterToCollection(Varien_Data_Collection_Db $collection, $groupId)
{
/* @var $helper Netzarbeiter_GroupsCatalog2_Helper_Data */
$helper = Mage::helper('netzarbeiter_groupscatalog2');
/**
* This is slightly complicated but it works with products and
* categories whether the flat tables enabled or not
*
* @var $entityType string
* @var $entity Mage_Catalog_Model_Abstract
*/
$entity = $collection->getNewEmptyItem();
$entityType = $helper->getEntityTypeCodeFromEntity($entity);
$this->_init($helper->getIndexTableByEntityType($entityType), 'id');
if ($this->_doesIndexExists()) {
$filterTable = $collection->getResource()->getTable($helper->getIndexTableByEntityType($entityType));
$entityIdField = "{$this->_getCollectionTableAlias($collection)}.entity_id";
$this->_addGroupsCatalogFilterToSelect($collection->getSelect(), $filterTable, $groupId, $collection->getStoreId(), $entityIdField);
}
}