本文整理汇总了PHP中Magento\Framework\App\Resource::getTableName方法的典型用法代码示例。如果您正苦于以下问题:PHP Resource::getTableName方法的具体用法?PHP Resource::getTableName怎么用?PHP Resource::getTableName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\App\Resource
的用法示例。
在下文中一共展示了Resource::getTableName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: processQueryWithField
/**
* @param FilterInterface $filter
* @param bool $isNegation
* @param string $query
* @return string
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
private function processQueryWithField(FilterInterface $filter, $isNegation, $query)
{
$currentStoreId = $this->scopeResolver->getScope()->getId();
$attribute = $this->config->getAttribute(\Magento\Catalog\Model\Product::ENTITY, $filter->getField());
$select = $this->getSelect();
$table = $attribute->getBackendTable();
if ($filter->getField() == 'price') {
$query = str_replace('price', 'min_price', $query);
$select->from(['main_table' => $this->resource->getTableName('catalog_product_index_price')], 'entity_id')->where($query);
} elseif ($filter->getField() == 'category_ids') {
return 'category_index.category_id = ' . $filter->getValue();
} else {
if ($attribute->isStatic()) {
$select->from(['main_table' => $table], 'entity_id')->where($query);
} else {
if ($filter->getType() == FilterInterface::TYPE_TERM) {
$field = $filter->getField();
$mapper = function ($value) use($field, $isNegation) {
return ($isNegation ? '-' : '') . $this->attributePrefix . $field . '_' . $value;
};
if (is_array($filter->getValue())) {
$value = implode(' ', array_map($mapper, $filter->getValue()));
} else {
$value = $mapper($filter->getValue());
}
return 'MATCH (data_index) AGAINST (' . $this->getConnection()->quote($value) . ' IN BOOLEAN MODE)';
}
$ifNullCondition = $this->getConnection()->getIfNullSql('current_store.value', 'main_table.value');
$select->from(['main_table' => $table], 'entity_id')->joinLeft(['current_store' => $table], 'current_store.attribute_id = main_table.attribute_id AND current_store.store_id = ' . $currentStoreId, null)->columns([$filter->getField() => $ifNullCondition])->where('main_table.attribute_id = ?', $attribute->getAttributeId())->where('main_table.store_id = ?', \Magento\Store\Model\Store::DEFAULT_STORE_ID)->having($query);
}
}
return 'search_index.product_id IN (
select entity_id from ' . $this->conditionManager->wrapBrackets($select) . ' as filter
)';
}
示例2: processQueryWithField
/**
* @param FilterInterface $filter
* @param bool $isNegation
* @param string $query
* @param QueryContainer $queryContainer
* @return string
*/
private function processQueryWithField(FilterInterface $filter, $isNegation, $query, QueryContainer $queryContainer)
{
$currentStoreId = $this->scopeResolver->getScope()->getId();
$attribute = $this->config->getAttribute(\Magento\Catalog\Model\Product::ENTITY, $filter->getField());
$select = $this->getConnection()->select();
$table = $attribute->getBackendTable();
if ($filter->getField() == 'price') {
$query = str_replace('price', 'min_price', $query);
$select->from(['main_table' => $this->resource->getTableName('catalog_product_index_price')], 'entity_id')->where($query);
} elseif ($filter->getField() == 'category_ids') {
return 'category_index.category_id = ' . $filter->getValue();
} else {
if ($attribute->isStatic()) {
$select->from(['main_table' => $table], 'entity_id')->where($query);
} else {
if ($filter->getType() == FilterInterface::TYPE_TERM) {
if (is_array($filter->getValue())) {
$value = sprintf('%s IN (%s)', $isNegation ? 'NOT' : '', implode(',', $filter->getValue()));
} else {
$value = ($isNegation ? '!' : '') . '= ' . $filter->getValue();
}
$filterQuery = sprintf('cpie.store_id = %d AND cpie.attribute_id = %d AND cpie.value %s', $this->scopeResolver->getScope()->getId(), $attribute->getId(), $value);
$queryContainer->addFilter($filterQuery);
return '';
}
$ifNullCondition = $this->getConnection()->getIfNullSql('current_store.value', 'main_table.value');
$select->from(['main_table' => $table], 'entity_id')->joinLeft(['current_store' => $table], 'current_store.attribute_id = main_table.attribute_id AND current_store.store_id = ' . $currentStoreId, null)->columns([$filter->getField() => $ifNullCondition])->where('main_table.attribute_id = ?', $attribute->getAttributeId())->where('main_table.store_id = ?', \Magento\Store\Model\Store::DEFAULT_STORE_ID)->having($query);
}
}
return 'search_index.entity_id IN (
select entity_id from ' . $this->conditionManager->wrapBrackets($select) . ' as filter
)';
}
示例3: loadLogData
/**
* Load customer log data by customer id
*
* @param int $customerId
* @return array
*/
protected function loadLogData($customerId)
{
/** @var \Magento\Framework\DB\Adapter\AdapterInterface $adapter */
$adapter = $this->resource->getConnection('read');
$select = $adapter->select()->from(['cl' => $this->resource->getTableName('customer_log')])->joinLeft(['cv' => $this->resource->getTableName('customer_visitor')], 'cv.customer_id = cl.customer_id', ['last_visit_at'])->where('cl.customer_id = ?', $customerId)->order('cv.visitor_id DESC')->limit(1);
return $adapter->fetchRow($select);
}
示例4: testPrepareProductIndexForBundleProduct
/**
* @magentoDataFixture Magento/Bundle/_files/product.php
* @covers \Magento\Indexer\Model\Indexer::reindexAll
* @covers \Magento\Bundle\Model\Product\Type::getSearchableData
*/
public function testPrepareProductIndexForBundleProduct()
{
$this->indexer->reindexAll();
$select = $this->adapter->select()->from($this->resource->getTableName('catalogsearch_fulltext_scope1'))->where('`data_index` LIKE ?', '%' . 'Bundle Product Items' . '%');
$result = $this->adapter->fetchAll($select);
$this->assertCount(1, $result);
}
示例5: executeFull
/**
* Execute full indexation
*
* @return void
*/
public function executeFull()
{
$results = [];
foreach ($this->getTables() as $table => $columns) {
if (!count($columns)) {
continue;
}
foreach ($columns as $idx => $col) {
$columns[$idx] = '`' . $col . '`';
}
$select = $this->connection->select();
$fromColumns = new \Zend_Db_Expr('CONCAT(' . implode(",' ',", $columns) . ') as data_index');
$select->from($table, $fromColumns);
$result = $this->connection->query($select);
while ($row = $result->fetch()) {
$data = $row['data_index'];
$this->split($data, $results);
}
}
$indexTable = $this->resource->getTableName('mst_misspell_index');
$this->connection->delete($indexTable);
$rows = [];
foreach ($results as $word => $freq) {
$rows[] = ['keyword' => $word, 'trigram' => $this->text->getTrigram($word), 'frequency' => $freq / count($results)];
if (count($rows) > 1000) {
$this->connection->insertArray($indexTable, ['keyword', 'trigram', 'frequency'], $rows);
$rows = [];
}
}
if (count($rows) > 0) {
$this->connection->insertArray($indexTable, ['keyword', 'trigram', 'frequency'], $rows);
}
$this->connection->delete($this->resource->getTableName('mst_misspell_suggest'));
}
示例6: getTable
/**
* Get table name (validated by db adapter) by table placeholder
*
* @param string|array $tableName
* @return string
*/
public function getTable($tableName)
{
$cacheKey = $this->_getTableCacheName($tableName);
if (!isset($this->tables[$cacheKey])) {
$this->tables[$cacheKey] = $this->resourceModel->getTableName($tableName);
}
return $this->tables[$cacheKey];
}
示例7: build
/**
* Build index query
*
* @param RequestInterface $request
* @return Select
*/
public function build(RequestInterface $request)
{
$select = $this->getSelect()->from(['search_index' => $this->resource->getTableName($request->getIndex())], ['entity_id' => 'search_index.product_id'])->joinLeft(['category_index' => $this->resource->getTableName('catalog_category_product_index')], 'search_index.product_id = category_index.product_id' . ' AND search_index.store_id = category_index.store_id', []);
$isShowOutOfStock = $this->config->isSetFlag('cataloginventory/options/show_out_of_stock', ScopeInterface::SCOPE_STORE);
if ($isShowOutOfStock === false) {
$select->joinLeft(['stock_index' => $this->resource->getTableName('cataloginventory_stock_status')], 'search_index.product_id = stock_index.product_id' . $this->getReadConnection()->quoteInto(' AND stock_index.website_id = ?', $this->storeManager->getWebsite()->getId()), [])->where('stock_index.stock_status = ?', 1);
}
return $select;
}
示例8: testAggregate
/**
* @magentoDataFixture Magento/Review/_files/customer_review_with_rating.php
*/
public function testAggregate()
{
$rating = $this->reviewCollection->getFirstItem();
$this->reviewResource->aggregate($rating);
$select = $this->adapter->select()->from($this->resource->getTableName('review_entity_summary'));
$result = $this->adapter->fetchRow($select);
$this->assertEquals(1, $result['reviews_count']);
$this->assertEquals(40, $result['rating_summary']);
}
示例9: getAggregations
/**
* {@inheritdoc}
*/
public function getAggregations(array $entityIds)
{
$aggregation = ['count' => 'count(DISTINCT entity_id)', 'max' => 'MAX(min_price)', 'min' => 'MIN(min_price)', 'std' => 'STDDEV_SAMP(min_price)'];
$select = $this->getSelect();
$tableName = $this->resource->getTableName('catalog_product_index_price');
$select->from($tableName, [])->where('entity_id IN (?)', $entityIds)->columns($aggregation);
$select = $this->setCustomerGroupId($select);
$result = $this->getConnection()->fetchRow($select);
return $result;
}
示例10: testGetTableName
public function testGetTableName()
{
$tablePrefix = 'prefix_';
$tableSuffix = 'suffix';
$tableNameOrig = 'store_website';
$this->_model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Framework\\App\\Resource', array('tablePrefix' => 'prefix_'));
$tableName = $this->_model->getTableName(array($tableNameOrig, $tableSuffix));
$this->assertContains($tablePrefix, $tableName);
$this->assertContains($tableSuffix, $tableName);
$this->assertContains($tableNameOrig, $tableName);
}
示例11: mockBuild
protected function mockBuild($index, $tableSuffix)
{
$this->request->expects($this->once())->method('getIndex')->will($this->returnValue($index));
$this->resource->expects($this->any())->method('getTableName')->will($this->returnCallback(function ($index) {
return is_array($index) ? $index[0] . $index[1] : $index;
}));
$this->select->expects($this->once())->method('from')->with(['search_index' => $index . $tableSuffix], ['entity_id' => 'product_id'])->will($this->returnSelf());
$this->select->expects($this->at(1))->method('joinLeft')->with(['category_index' => 'catalog_category_product_index'], 'search_index.product_id = category_index.product_id' . ' AND search_index.store_id = category_index.store_id', [])->will($this->returnSelf());
$this->select->expects($this->at(2))->method('joinLeft')->with(['cea' => 'catalog_eav_attribute'], 'search_index.attribute_id = cea.attribute_id', ['search_weight'])->will($this->returnSelf());
$this->select->expects($this->at(3))->method('joinLeft')->with(['cpie' => $this->resource->getTableName('catalog_product_index_eav')], 'search_index.product_id = cpie.entity_id AND search_index.attribute_id = cpie.attribute_id', [])->willReturnSelf();
}
示例12: generateSequences
/**
* @param int $n
* @return void
*/
public function generateSequences($n = 10)
{
$connection = $this->appResource->getConnection('write');
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));
}
}
}
}
示例13: getTablesInfo
/**
* Retrieves information about log tables
*
* @return string[]
*/
public function getTablesInfo()
{
$tables = ['log_customer', 'log_visitor', 'log_visitor_info', 'log_url_table', 'log_url_info_table', 'log_quote_table', 'reports_viewed_product_index', 'reports_compared_product_index', 'reports_event', 'catalog_compare_item'];
$result = [];
foreach ($tables as $table) {
$info = $this->_resourceHelper->getTableInfo($this->_resource->getTableName($table));
if (!$info) {
continue;
}
$result[] = $info;
}
return $result;
}
示例14: resolve
/**
* @param string $index
* @param Dimension[] $dimensions
* @return string
*/
public function resolve($index, array $dimensions)
{
$tableNameParts = [$index];
foreach ($dimensions as $dimension) {
switch ($dimension->getName()) {
case 'scope':
$tableNameParts[] = $dimension->getName() . $this->getScopeId($dimension);
break;
default:
$tableNameParts[] = $dimension->getName() . $dimension->getValue();
}
}
return $this->resource->getTableName(implode('_', $tableNameParts));
}
示例15: build
/**
* Build index query
*
* @param RequestInterface $request
* @return Select
*/
public function build(RequestInterface $request)
{
$searchIndexTable = $this->scopeResolver->resolve($request->getIndex(), $request->getDimensions());
$select = $this->getSelect()->from(['search_index' => $searchIndexTable], ['entity_id' => 'entity_id'])->joinLeft(['cea' => $this->resource->getTableName('catalog_eav_attribute')], 'search_index.attribute_id = cea.attribute_id', []);
if ($this->isNeedToAddFilters($request)) {
$select->joinLeft(['category_index' => $this->resource->getTableName('catalog_category_product_index')], 'search_index.entity_id = category_index.product_id', [])->joinLeft(['cpie' => $this->resource->getTableName('catalog_product_index_eav')], 'search_index.entity_id = cpie.entity_id AND search_index.attribute_id = cpie.attribute_id', []);
}
$select = $this->processDimensions($request, $select);
$isShowOutOfStock = $this->config->isSetFlag('cataloginventory/options/show_out_of_stock', ScopeInterface::SCOPE_STORE);
if ($isShowOutOfStock === false) {
$select->joinLeft(['stock_index' => $this->resource->getTableName('cataloginventory_stock_status')], 'search_index.entity_id = stock_index.product_id' . $this->getReadConnection()->quoteInto(' AND stock_index.website_id = ?', $this->storeManager->getWebsite()->getId()), []);
$select->where('stock_index.stock_status = ?', 1);
}
return $select;
}