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


PHP AdapterInterface::fetchPairs方法代码示例

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


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

示例1: saveLinksData

 /**
  * @param array $linksData
  * @return void
  */
 public function saveLinksData($linksData)
 {
     $mainTable = $this->productLink->getMainTable();
     $relationTable = $this->productLink->getTable('catalog_product_relation');
     // save links and relations
     if ($linksData['product_ids']) {
         $this->deleteOldLinks(array_keys($linksData['product_ids']));
         $mainData = [];
         foreach ($linksData['relation'] as $productData) {
             $mainData[] = ['product_id' => $productData['parent_id'], 'linked_product_id' => $productData['child_id'], 'link_type_id' => $this->getLinkTypeId()];
         }
         $this->connection->insertOnDuplicate($mainTable, $mainData);
         $this->connection->insertOnDuplicate($relationTable, $linksData['relation']);
     }
     $attributes = $this->getAttributes();
     // save positions and default quantity
     if ($linksData['attr_product_ids']) {
         $savedData = $this->connection->fetchPairs($this->connection->select()->from($mainTable, [new \Zend_Db_Expr('CONCAT_WS(" ", product_id, linked_product_id)'), 'link_id'])->where('product_id IN (?) AND link_type_id = ' . $this->connection->quote($this->getLinkTypeId()), array_keys($linksData['attr_product_ids'])));
         foreach ($savedData as $pseudoKey => $linkId) {
             if (isset($linksData['position'][$pseudoKey])) {
                 $linksData['position'][$pseudoKey]['link_id'] = $linkId;
             }
             if (isset($linksData['qty'][$pseudoKey])) {
                 $linksData['qty'][$pseudoKey]['link_id'] = $linkId;
             }
         }
         if (!empty($linksData['position'])) {
             $this->connection->insertOnDuplicate($attributes['position']['table'], $linksData['position']);
         }
         if (!empty($linksData['qty'])) {
             $this->connection->insertOnDuplicate($attributes['qty']['table'], $linksData['qty']);
         }
     }
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:38,代码来源:Links.php

示例2: getAggregation

 /**
  * {@inheritdoc}
  */
 public function getAggregation(BucketInterface $bucket, array $dimensions, $range, \Magento\Framework\Search\Dynamic\EntityStorage $entityStorage)
 {
     $select = $this->dataProvider->getDataSet($bucket, $dimensions, $entityStorage->getSource());
     $column = $select->getPart(Select::COLUMNS)[0];
     $select->reset(Select::COLUMNS);
     $rangeExpr = new \Zend_Db_Expr($this->connection->quoteInto('(FLOOR(' . $column[1] . ' / ? ) + 1)', $range));
     $select->columns(['range' => $rangeExpr])->columns(['metrix' => 'COUNT(*)'])->group('range')->order('range');
     $result = $this->connection->fetchPairs($select);
     return $result;
 }
开发者ID:whoople,项目名称:magento2-testing,代码行数:13,代码来源:DataProvider.php

示例3: _reindexRows

 /**
  * Refresh entities index
  *
  * @param array $changedIds
  * @return array Affected ids
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  */
 protected function _reindexRows($changedIds = [])
 {
     $this->_emptyTable($this->_getIdxTable());
     $this->_prepareWebsiteDateTable();
     $select = $this->_connection->select()->from($this->_getTable('catalog_product_entity'), ['entity_id', 'type_id'])->where('entity_id IN(?)', $changedIds);
     $pairs = $this->_connection->fetchPairs($select);
     $byType = [];
     foreach ($pairs as $productId => $productType) {
         $byType[$productType][$productId] = $productId;
     }
     $compositeIds = [];
     $notCompositeIds = [];
     foreach ($byType as $productType => $entityIds) {
         $indexer = $this->_getIndexer($productType);
         if ($indexer->getIsComposite()) {
             $compositeIds += $entityIds;
         } else {
             $notCompositeIds += $entityIds;
         }
     }
     if (!empty($notCompositeIds)) {
         $select = $this->_connection->select()->from(['l' => $this->_getTable('catalog_product_relation')], 'parent_id')->join(['e' => $this->_getTable('catalog_product_entity')], 'e.entity_id = l.parent_id', ['type_id'])->where('l.child_id IN(?)', $notCompositeIds);
         $pairs = $this->_connection->fetchPairs($select);
         foreach ($pairs as $productId => $productType) {
             if (!in_array($productId, $changedIds)) {
                 $changedIds[] = $productId;
                 $byType[$productType][$productId] = $productId;
                 $compositeIds[$productId] = $productId;
             }
         }
     }
     if (!empty($compositeIds)) {
         $this->_copyRelationIndexData($compositeIds, $notCompositeIds);
     }
     $this->_prepareTierPriceIndex($compositeIds + $notCompositeIds);
     $this->_prepareGroupPriceIndex($compositeIds + $notCompositeIds);
     $indexers = $this->getTypeIndexers();
     foreach ($indexers as $indexer) {
         if (!empty($byType[$indexer->getTypeId()])) {
             $indexer->reindexEntity($byType[$indexer->getTypeId()]);
         }
     }
     $this->_syncData($changedIds);
     return $compositeIds + $notCompositeIds;
 }
开发者ID:opexsw,项目名称:magento2,代码行数:52,代码来源:AbstractAction.php

示例4: getProductAttributes

 /**
  * Load product(s) attributes
  *
  * @param int $storeId
  * @param array $productIds
  * @param array $attributeTypes
  * @return array
  */
 public function getProductAttributes($storeId, array $productIds, array $attributeTypes)
 {
     $result = [];
     $selects = [];
     $ifStoreValue = $this->connection->getCheckSql('t_store.value_id > 0', 't_store.value', 't_default.value');
     $linkField = $this->metadata->getLinkField();
     $productLinkFieldsToEntityIdMap = $this->connection->fetchPairs($this->connection->select()->from(['cpe' => $this->getTable('catalog_product_entity')], [$linkField, 'entity_id'])->where('cpe.entity_id IN (?)', $productIds));
     foreach ($attributeTypes as $backendType => $attributeIds) {
         if ($attributeIds) {
             $tableName = $this->getTable('catalog_product_entity_' . $backendType);
             $selects[] = $this->connection->select()->from(['t_default' => $tableName], [$linkField, 'attribute_id'])->joinLeft(['t_store' => $tableName], $this->connection->quoteInto('t_default.' . $linkField . '=t_store.' . $linkField . ' AND t_default.attribute_id=t_store.attribute_id' . ' AND t_store.store_id = ?', $storeId), ['value' => $this->unifyField($ifStoreValue, $backendType)])->where('t_default.store_id = ?', 0)->where('t_default.attribute_id IN (?)', $attributeIds)->where('t_default.' . $linkField . ' IN (?)', array_keys($productLinkFieldsToEntityIdMap));
         }
     }
     if ($selects) {
         $select = $this->connection->select()->union($selects, \Magento\Framework\DB\Select::SQL_UNION_ALL);
         $query = $this->connection->query($select);
         while ($row = $query->fetch()) {
             $entityId = $productLinkFieldsToEntityIdMap[$row[$linkField]];
             $result[$entityId][$row['attribute_id']] = $row['value'];
         }
     }
     return $result;
 }
开发者ID:BlackIkeEagle,项目名称:magento2-continuousphp,代码行数:31,代码来源:DataProvider.php

示例5: retrieveProducsByCachedSkus

 /**
  * Retrieve mapping between skus and products.
  *
  * @return \Magento\CatalogImportExport\Model\Import\Product\Type\AbstractType
  */
 protected function retrieveProducsByCachedSkus()
 {
     $this->_cachedSkuToProducts = $this->connection->fetchPairs($this->connection->select()->from($this->_resource->getTableName('catalog_product_entity'), ['sku', 'entity_id'])->where('sku IN (?)', $this->_cachedSkus));
     return $this;
 }
开发者ID:nja78,项目名称:magento2,代码行数:10,代码来源:Bundle.php


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