當前位置: 首頁>>代碼示例>>PHP>>正文


PHP AbstractCollection::_beforeLoad方法代碼示例

本文整理匯總了PHP中Magento\Framework\Model\Resource\Db\Collection\AbstractCollection::_beforeLoad方法的典型用法代碼示例。如果您正苦於以下問題:PHP AbstractCollection::_beforeLoad方法的具體用法?PHP AbstractCollection::_beforeLoad怎麽用?PHP AbstractCollection::_beforeLoad使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Magento\Framework\Model\Resource\Db\Collection\AbstractCollection的用法示例。


在下文中一共展示了AbstractCollection::_beforeLoad方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: _beforeLoad

 /**
  * Load collection data
  *
  * @return $this
  */
 public function _beforeLoad()
 {
     if (!$this->getLoadDefault()) {
         $this->setWithoutDefaultFilter();
     }
     $this->addOrder('main_table.name', self::SORT_ORDER_ASC);
     return parent::_beforeLoad();
 }
開發者ID:shabbirvividads,項目名稱:magento2,代碼行數:13,代碼來源:Collection.php

示例2: _beforeLoad

 /**
  * Prepare filters
  *
  * @return $this
  */
 protected function _beforeLoad()
 {
     parent::_beforeLoad();
     if ($this->isLoaded()) {
         return $this;
     }
     // filters
     if ($this->_createdBefore) {
         $this->getSelect()->where('main_table.created_at < ?', $this->_createdBefore);
     }
     return $this;
 }
開發者ID:aiesh,項目名稱:magento2,代碼行數:17,代碼來源:Collection.php

示例3: _beforeLoad

 /**
  * Add joins to select
  *
  * @return $this
  */
 protected function _beforeLoad()
 {
     $select = $this->getSelect();
     $connection = $this->getConnection();
     $entityType = $this->getEntityType();
     $this->setItemObjectClass($entityType->getAttributeModel());
     $eaColumns = [];
     $caColumns = [];
     $saColumns = [];
     $eaDescribe = $connection->describeTable($this->getTable('eav_attribute'));
     unset($eaDescribe['attribute_id']);
     foreach (array_keys($eaDescribe) as $columnName) {
         $eaColumns[$columnName] = $columnName;
     }
     $select->join(['ea' => $this->getTable('eav_attribute')], 'main_table.attribute_id = ea.attribute_id', $eaColumns);
     // join additional attribute data table
     $additionalTable = $entityType->getAdditionalAttributeTable();
     if ($additionalTable) {
         $caDescribe = $connection->describeTable($this->getTable($additionalTable));
         unset($caDescribe['attribute_id']);
         foreach (array_keys($caDescribe) as $columnName) {
             $caColumns[$columnName] = $columnName;
         }
         $select->join(['ca' => $this->getTable($additionalTable)], 'main_table.attribute_id = ca.attribute_id', $caColumns);
     }
     // add scope values
     if ($this->_getEavWebsiteTable()) {
         $saDescribe = $connection->describeTable($this->_getEavWebsiteTable());
         unset($saDescribe['attribute_id']);
         foreach (array_keys($saDescribe) as $columnName) {
             if ($columnName == 'website_id') {
                 $saColumns['scope_website_id'] = $columnName;
             } else {
                 if (isset($eaColumns[$columnName])) {
                     $code = sprintf('scope_%s', $columnName);
                     $expression = $connection->getCheckSql('sa.%s IS NULL', 'ea.%s', 'sa.%s');
                     $saColumns[$code] = new \Zend_Db_Expr(sprintf($expression, $columnName, $columnName, $columnName));
                 } elseif (isset($caColumns[$columnName])) {
                     $code = sprintf('scope_%s', $columnName);
                     $expression = $connection->getCheckSql('sa.%s IS NULL', 'ca.%s', 'sa.%s');
                     $saColumns[$code] = new \Zend_Db_Expr(sprintf($expression, $columnName, $columnName, $columnName));
                 }
             }
         }
         $store = $this->getStore();
         $joinWebsiteExpression = $connection->quoteInto('sa.attribute_id = main_table.attribute_id AND sa.website_id = ?', (int) $store->getWebsiteId());
         $select->joinLeft(['sa' => $this->_getEavWebsiteTable()], $joinWebsiteExpression, $saColumns);
     }
     // add store attribute label
     $storeLabelExpr = $connection->getCheckSql('al.value IS NULL', 'ea.frontend_label', 'al.value');
     $joinExpression = $connection->quoteInto('al.attribute_id = main_table.attribute_id AND al.store_id = ?', (int) $store->getId());
     $select->joinLeft(['al' => $this->getTable('eav_attribute_label')], $joinExpression, ['store_label' => $storeLabelExpr]);
     // add entity type filter
     $select->where('ea.entity_type_id = ?', (int) $entityType->getId());
     return parent::_beforeLoad();
 }
開發者ID:shabbirvividads,項目名稱:magento2,代碼行數:61,代碼來源:Collection.php

示例4: _beforeLoad

 /**
  * Before collection load
  *
  * @return $this
  */
 protected function _beforeLoad()
 {
     $this->_eventManager->dispatch($this->_eventPrefix . '_load_before', [$this->_eventObject => $this]);
     return parent::_beforeLoad();
 }
開發者ID:shabbirvividads,項目名稱:magento2,代碼行數:10,代碼來源:Collection.php

示例5: _beforeLoad

 /**
  * Apply filters common to reports
  *
  * @return $this
  */
 protected function _beforeLoad()
 {
     parent::_beforeLoad();
     $this->_applyAggregatedTable();
     $this->_applyDateRangeFilter();
     $this->_applyStoresFilter();
     $this->_applyCustomFilter();
     return $this;
 }
開發者ID:aiesh,項目名稱:magento2,代碼行數:14,代碼來源:AbstractCollection.php


注:本文中的Magento\Framework\Model\Resource\Db\Collection\AbstractCollection::_beforeLoad方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。