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


PHP ResourceConnection::getConnection方法代码示例

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


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

示例1: getConnection

 /**
  * @return \Magento\Framework\DB\Adapter\AdapterInterface
  */
 protected function getConnection()
 {
     if (!$this->connection) {
         $this->connection = $this->resource->getConnection('sales');
     }
     return $this->connection;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:10,代码来源:Attribute.php

示例2: getConnection

 /**
  * Returns Adapter interface
  *
  * @return array \Magento\Framework\DB\Adapter\AdapterInterface
  */
 public function getConnection()
 {
     if (!$this->connection) {
         $this->connection = $this->resource->getConnection(\Magento\Framework\App\ResourceConnection::DEFAULT_CONNECTION);
     }
     return $this->connection;
 }
开发者ID:andrewhowdencom,项目名称:m2onk8s,代码行数:12,代码来源:InvoiceItemInterfacePersistor.php

示例3: install

 /**
  * {@inheritdoc}
  */
 public function install(array $fixtures)
 {
     /** @var \Magento\Framework\DB\Adapter\AdapterInterface $adapter */
     $adapter = $this->resource->getConnection('core_write');
     $regions = $this->loadDirectoryRegions();
     foreach ($fixtures as $fileName) {
         $fileName = $this->fixtureManager->getFixture($fileName);
         if (!file_exists($fileName)) {
             continue;
         }
         $rows = $this->csvReader->getData($fileName);
         $header = array_shift($rows);
         foreach ($rows as $row) {
             $data = [];
             foreach ($row as $key => $value) {
                 $data[$header[$key]] = $value;
             }
             $regionId = $data['region'] != '*' ? $regions[$data['country']][$data['region']] : 0;
             try {
                 $adapter->insert($this->tablerate->getMainTable(), ['website_id' => $this->storeManager->getWebsite()->getId(), 'dest_country_id' => $data['country'], 'dest_region_id' => $regionId, 'dest_zip' => $data['zip'], 'condition_name' => 'package_value', 'condition_value' => $data['order_subtotal'], 'price' => $data['price'], 'cost' => 0]);
             } catch (\Zend_Db_Statement_Exception $e) {
                 if ($e->getCode() == self::ERROR_CODE_DUPLICATE_ENTRY) {
                     // In case if Sample data was already installed we just skip duplicated records installation
                     continue;
                 } else {
                     throw $e;
                 }
             }
         }
     }
     $this->configWriter->save('carriers/tablerate/active', 1);
     $this->configWriter->save('carriers/tablerate/condition_name', 'package_value');
     $this->cacheTypeList->cleanType('config');
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:37,代码来源:Tablerate.php

示例4: getConnection

 /**
  * Get connection object
  *
  * @return \Magento\Framework\DB\Adapter\AdapterInterface
  */
 public function getConnection()
 {
     if (null === $this->connection) {
         $this->connection = $this->resourceModel->getConnection($this->connectionName);
     }
     return $this->connection;
 }
开发者ID:hientruong90,项目名称:magento2_installer,代码行数:12,代码来源:Setup.php

示例5: setUp

 /**
  * @return void
  */
 protected function setUp()
 {
     $this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
     $this->resource = $this->objectManager->get('Magento\\Framework\\App\\ResourceConnection');
     $this->connection = $this->resource->getConnection();
     $this->reviewCollection = $this->objectManager->create('Magento\\Review\\Model\\ResourceModel\\Review\\Collection');
     $this->reviewResource = $this->objectManager->create('Magento\\Review\\Model\\ResourceModel\\Review');
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:11,代码来源:ReviewTest.php

示例6: build

 /**
  * {@inheritdoc}
  */
 public function build($productId)
 {
     $timestamp = $this->localeDate->scopeTimeStamp($this->storeManager->getStore());
     $currentDate = $this->dateTime->formatDate($timestamp, false);
     $linkField = $this->metadataPool->getMetadata(ProductInterface::class)->getLinkField();
     $productTable = $this->resource->getTableName('catalog_product_entity');
     return [$this->resource->getConnection()->select()->from(['parent' => $productTable], '')->joinInner(['link' => $this->resource->getTableName('catalog_product_relation')], "link.parent_id = parent.{$linkField}", [])->joinInner(['child' => $productTable], "child.entity_id = link.child_id", ['entity_id'])->joinInner(['t' => $this->resource->getTableName('catalogrule_product_price')], 't.product_id = child.entity_id', [])->where('parent.entity_id = ? ', $productId)->where('t.website_id = ?', $this->storeManager->getStore()->getWebsiteId())->where('t.customer_group_id = ?', $this->customerSession->getCustomerGroupId())->where('t.rule_date = ?', $currentDate)->order('t.rule_price ' . Select::SQL_ASC)->limit(1)];
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:11,代码来源:LinkedProductSelectBuilderByCatalogRulePrice.php

示例7: getConnection

 public function getConnection($name = null)
 {
     if (is_null($name)) {
         $name = \Magento\Framework\App\ResourceConnection::DEFAULT_CONNECTION;
     }
     $result = $this->_resource->getConnection($name);
     return $result;
 }
开发者ID:praxigento,项目名称:mobi_mod_mage2_core,代码行数:8,代码来源:Db.php

示例8: setUp

 /**
  * @return void
  */
 public function setUp()
 {
     $this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
     $this->resource = $this->objectManager->get('Magento\\Framework\\App\\ResourceConnection');
     $this->connection = $this->resource->getConnection();
     $this->model = $this->objectManager->create('Magento\\Framework\\Mview\\View\\Changelog', ['resource' => $this->resource]);
     $this->model->setViewId('test_view_id_1');
     $this->model->create();
 }
开发者ID:andrewhowdencom,项目名称:m2onk8s,代码行数:12,代码来源:ChangelogTest.php

示例9: getIds

 /**
  * @param array $ids
  * @return array
  */
 public function getIds(array $ids)
 {
     $key = md5(json_encode($ids));
     if (!isset($this->productIds[$key])) {
         $connection = $this->resource->getConnection();
         $this->productIds[$key] = $connection->fetchCol($connection->select()->from(['e' => $this->resource->getTableName('catalog_product_entity')], ['e.entity_id'])->where('e.type_id = ?', \Magento\ConfigurableProduct\Model\Product\Type\Configurable::TYPE_CODE)->where('e.entity_id IN (?)', $ids));
     }
     return $this->productIds[$key];
 }
开发者ID:BlackIkeEagle,项目名称:magento2-continuousphp,代码行数:13,代码来源:ConfigurableProductsProvider.php

示例10: setUp

 protected function setUp()
 {
     $this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
     /** @var \Magento\Framework\Indexer\IndexerRegistry $indexerRegistry */
     $indexerRegistry = $this->objectManager->create('\\Magento\\Framework\\Indexer\\IndexerRegistry');
     $this->indexer = $indexerRegistry->get('catalogsearch_fulltext');
     $this->resource = $this->objectManager->get('Magento\\Framework\\App\\ResourceConnection');
     $this->connectionMock = $this->resource->getConnection();
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:9,代码来源:TypeTest.php

示例11: beforeLoad

 /**
  * @param Collection $productCollection
  * @param bool $printQuery
  * @param bool $logQuery
  * @return array
  */
 public function beforeLoad(Collection $productCollection, $printQuery = false, $logQuery = false)
 {
     if (!$productCollection->hasFlag('catalog_rule_loaded')) {
         $connection = $this->resource->getConnection();
         $store = $this->storeManager->getStore();
         $productCollection->getSelect()->joinLeft(['catalog_rule' => $this->resource->getTableName('catalogrule_product_price')], implode(' AND ', ['catalog_rule.product_id = e.entity_id', $connection->quoteInto('catalog_rule.website_id = ?', $store->getWebsiteId()), $connection->quoteInto('catalog_rule.customer_group_id = ?', $this->customerSession->getCustomerGroupId()), $connection->quoteInto('catalog_rule.rule_date = ?', $this->dateTime->formatDate($this->localeDate->scopeDate($store->getId()), false))]), [CatalogRulePrice::PRICE_CODE => 'rule_price']);
         $productCollection->setFlag('catalog_rule_loaded', true);
     }
     return [$printQuery, $logQuery];
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:16,代码来源:AddCatalogRulePrice.php

示例12: generateSequences

 /**
  * @param int $n
  * @return void
  */
 public function generateSequences($n = 10)
 {
     $connection = $this->appResource->getConnection();
     for ($i = 0; $i < $n; $i++) {
         foreach ($this->entities as $entityName) {
             $sequenceName = $this->appResource->getTableName(sprintf('sequence_%s_%s', $entityName, $i));
             if (!$connection->isTableExists($sequenceName)) {
                 $connection->query($this->ddlSequence->getCreateSequenceDdl($sequenceName));
             }
         }
     }
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:16,代码来源:Sequence.php

示例13: getProducts

 /**
  * {@inheritdoc}
  */
 public function getProducts(ProductInterface $product)
 {
     if (!isset($this->products[$product->getId()])) {
         if ($this->requestSafety->isSafeMethod()) {
             $productIds = $this->resource->getConnection()->fetchCol('(' . implode(') UNION (', $this->linkedProductSelectBuilder->build($product->getId())) . ')');
             $this->products[$product->getId()] = $this->collectionFactory->create()->addAttributeToSelect(['price', 'special_price'])->addIdFilter($productIds);
         } else {
             $this->products[$product->getId()] = $this->configurable->getUsedProducts($product);
         }
     }
     return $this->products[$product->getId()];
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:15,代码来源:ConfigurableOptionsProvider.php

示例14: move

 /**
  * Move data from temporary tables to flat
  *
  * @param string $flatTable
  * @param string $flatDropName
  * @param string $temporaryFlatTableName
  * @return void
  */
 public function move($flatTable, $flatDropName, $temporaryFlatTableName)
 {
     $connection = $this->_resource->getConnection();
     $renameTables = [];
     if ($connection->isTableExists($flatTable)) {
         $renameTables[] = ['oldName' => $flatTable, 'newName' => $flatDropName];
     }
     $renameTables[] = ['oldName' => $temporaryFlatTableName, 'newName' => $flatTable];
     $connection->dropTable($flatDropName);
     $connection->renameTablesBatch($renameTables);
     $connection->dropTable($flatDropName);
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:20,代码来源:TableData.php

示例15: build

 /**
  * {@inheritdoc}
  */
 public function build($productId)
 {
     $linkField = $this->metadataPool->getMetadata(ProductInterface::class)->getLinkField();
     $productTable = $this->resource->getTableName('catalog_product_entity');
     $priceSelect = $this->resource->getConnection()->select()->from(['parent' => $productTable], '')->joinInner(['link' => $this->resource->getTableName('catalog_product_relation')], "link.parent_id = parent.{$linkField}", [])->joinInner(['child' => $productTable], "child.entity_id = link.child_id", ['entity_id'])->joinInner(['t' => $this->resource->getTableName('catalog_product_entity_tier_price')], "t.{$linkField} = child.{$linkField}", [])->where('parent.entity_id = ? ', $productId)->where('t.all_groups = 1 OR customer_group_id = ?', $this->customerSession->getCustomerGroupId())->where('t.qty = ?', 1)->order('t.value ' . Select::SQL_ASC)->limit(1);
     $priceSelectDefault = clone $priceSelect;
     $priceSelectDefault->where('t.website_id = ?', self::DEFAULT_WEBSITE_ID);
     $select[] = $priceSelectDefault;
     if (!$this->catalogHelper->isPriceGlobal()) {
         $priceSelect->where('t.website_id = ?', $this->storeManager->getStore()->getWebsiteId());
         $select[] = $priceSelect;
     }
     return $select;
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:17,代码来源:LinkedProductSelectBuilderByTierPrice.php


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