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


PHP AbstractCollection::getSelect方法代码示例

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


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

示例1: addIsUsedFilterCallback

 /**
  * Callback function that filters collection by field "Used" from grid
  *
  * @param AbstractCollection $collection
  * @param Column $column
  * @return void
  */
 public function addIsUsedFilterCallback($collection, $column)
 {
     $filterValue = $column->getFilter()->getCondition();
     $expression = $this->getConnection()->getCheckSql('main_table.times_used > 0', 1, 0);
     $conditionSql = $this->_getConditionSql($expression, $filterValue);
     $collection->getSelect()->where($conditionSql);
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:14,代码来源:Collection.php

示例2: _prepareCache

 /**
  * @param \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection $collection
  */
 protected function _prepareCache($collection)
 {
     $stmt = $collection->getSelect()->query();
     $ids = array();
     foreach ($stmt as $item) {
         $ids = array_merge($ids, array_map('intval', explode('/', $item['path'])));
     }
     $ids = array_unique($ids);
     if (empty($ids)) {
         return;
     }
     /* @var $attribute \Magento\Eav\Model\Attribute */
     $attribute = $collection->getFirstItem()->getResource()->getAttribute('name');
     $resource = $collection->getResource();
     $tableName = \Magento\Catalog\Model\Category::ENTITY . '_entity_' . $attribute->getBackendType();
     $dbSelect1 = $resource->getConnection()->select()->from($resource->getTable($tableName), new \Zend_Db_Expr('MAX(`store_id`)'))->where("`entity_id` = `ccev`.`entity_id`")->where("`attribute_id` = `ccev`.`attribute_id`")->where("`store_id` = 0 OR `store_id` = ?", $this->getStoreId());
     $dbSelect2 = $resource->getConnection()->select()->from(array('ccev' => $resource->getTable($tableName)), array('name' => 'value', 'category_id' => 'entity_id'))->where('ccev.entity_id IN (' . implode(',', $ids) . ')')->where('ccev.attribute_id = ?', $attribute->getAttributeId())->where('ccev.store_id = (' . $dbSelect1->__toString() . ')');
     $cacheData = array();
     foreach ($resource->getConnection()->fetchAll($dbSelect2) as $row) {
         $cacheData[$row['category_id']] = $row['name'];
     }
     $this->setData('categories_cache', $cacheData);
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:26,代码来源:Grid.php

示例3: testGetAllIdsWithBind

 public function testGetAllIdsWithBind()
 {
     $this->_model->getSelect()->where('code = :code');
     $this->_model->addBindParam('code', 'admin');
     $this->assertEquals(['0'], $this->_model->getAllIds());
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:6,代码来源:AbstractTest.php


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