本文整理汇总了PHP中Magento\Framework\DB\Select::join方法的典型用法代码示例。如果您正苦于以下问题:PHP Select::join方法的具体用法?PHP Select::join怎么用?PHP Select::join使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\DB\Select
的用法示例。
在下文中一共展示了Select::join方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: applyPriceRuleToIndexTable
/**
* Apply price rule price to price index table
*
* @param \Magento\Framework\DB\Select $select
* @param array|string $indexTable
* @param string $entityId
* @param string $customerGroupId
* @param string $websiteId
* @param array $updateFields the array of fields for compare with rule price and update
* @param string $websiteDate
* @return \Magento\CatalogRule\Model\ResourceModel\Rule\Product\Price
*/
public function applyPriceRuleToIndexTable(\Magento\Framework\DB\Select $select, $indexTable, $entityId, $customerGroupId, $websiteId, $updateFields, $websiteDate)
{
if (empty($updateFields)) {
return $this;
}
if (is_array($indexTable)) {
foreach ($indexTable as $k => $v) {
if (is_string($k)) {
$indexAlias = $k;
} else {
$indexAlias = $v;
}
break;
}
} else {
$indexAlias = $indexTable;
}
$select->join(['rp' => $this->getMainTable()], "rp.rule_date = {$websiteDate}", [])->where("rp.product_id = {$entityId} AND rp.website_id = {$websiteId} AND rp.customer_group_id = {$customerGroupId}");
foreach ($updateFields as $priceField) {
$priceCond = $this->getConnection()->quoteIdentifier([$indexAlias, $priceField]);
$priceExpr = $this->getConnection()->getCheckSql("rp.rule_price < {$priceCond}", 'rp.rule_price', $priceCond);
$select->columns([$priceField => $priceExpr]);
}
$query = $select->crossUpdateFromSelect($indexTable);
$this->getConnection()->query($query);
return $this;
}
示例2: _addFilter
/**
* Add attribute to filter
*
* @param int $storeId
* @param string $attributeCode
* @param mixed $value
* @param string $type
* @return \Magento\Framework\DB\Select|bool
*/
protected function _addFilter($storeId, $attributeCode, $value, $type = '=')
{
if (!$this->_select instanceof \Magento\Framework\DB\Select) {
return false;
}
if (!isset($this->_attributesCache[$attributeCode])) {
$attribute = $this->_categoryResource->getAttribute($attributeCode);
$this->_attributesCache[$attributeCode] = ['entity_type_id' => $attribute->getEntityTypeId(), 'attribute_id' => $attribute->getId(), 'table' => $attribute->getBackend()->getTable(), 'is_global' => $attribute->getIsGlobal(), 'backend_type' => $attribute->getBackendType()];
}
$attribute = $this->_attributesCache[$attributeCode];
switch ($type) {
case '=':
$conditionRule = '=?';
break;
case 'in':
$conditionRule = ' IN(?)';
break;
default:
return false;
break;
}
if ($attribute['backend_type'] == 'static') {
$this->_select->where('e.' . $attributeCode . $conditionRule, $value);
} else {
$this->_select->join(['t1_' . $attributeCode => $attribute['table']], 'e.entity_id = t1_' . $attributeCode . '.entity_id AND t1_' . $attributeCode . '.store_id = 0', [])->where('t1_' . $attributeCode . '.attribute_id=?', $attribute['attribute_id']);
if ($attribute['is_global']) {
$this->_select->where('t1_' . $attributeCode . '.value' . $conditionRule, $value);
} else {
$ifCase = $this->getConnection()->getCheckSql('t2_' . $attributeCode . '.value_id > 0', 't2_' . $attributeCode . '.value', 't1_' . $attributeCode . '.value');
$this->_select->joinLeft(['t2_' . $attributeCode => $attribute['table']], $this->getConnection()->quoteInto('t1_' . $attributeCode . '.entity_id = t2_' . $attributeCode . '.entity_id AND t1_' . $attributeCode . '.attribute_id = t2_' . $attributeCode . '.attribute_id AND t2_' . $attributeCode . '.store_id=?', $storeId), [])->where('(' . $ifCase . ')' . $conditionRule, $value);
}
}
return $this->_select;
}
示例3: _addProductWebsiteJoinToSelect
/**
* Add join for catalog/product_website table
* Joined table has alias pw
*
* @param \Magento\Framework\DB\Select $select the select object
* @param string|\Zend_Db_Expr $website the limitation of website_id
* @param string|\Zend_Db_Expr $product the limitation of product_id
* @return $this
*/
protected function _addProductWebsiteJoinToSelect($select, $website, $product)
{
$select->join(['pw' => $this->getTable('catalog_product_website')], "pw.product_id = {$product} AND pw.website_id = {$website}", []);
return $this;
}
示例4: prepareCatalogProductIndexSelect
/**
* Add stock status limitation to catalog product price index select object
*
* @param \Magento\Framework\DB\Select $select
* @param string|\Zend_Db_Expr $entityField
* @param string|\Zend_Db_Expr $websiteField
* @return $this
*/
public function prepareCatalogProductIndexSelect(\Magento\Framework\DB\Select $select, $entityField, $websiteField)
{
$select->join(array('ciss' => $this->getMainTable()), "ciss.product_id = {$entityField} AND ciss.website_id = {$websiteField}", array());
$select->where('ciss.stock_status = ?', Stock\Status::STATUS_IN_STOCK);
return $this;
}
示例5: applyCondition
protected function applyCondition(Select $select)
{
$select->join(['id' => $this->tableName], 'attribute.entity_id = id.entity_id', []);
}
示例6: limitFlatActive
public function limitFlatActive(Select $select, $alias = 'main')
{
$select->join(['flat' => $this->getTable('entity_flat')], $alias . '.entity_id = flat.entity_id', []);
$select->where('flat.scope_id = ?', $this->scope->getId($this->scopeCode));
$select->where('flat.is_active = ?', 1);
return $this;
}