本文整理汇总了PHP中Magento\Framework\DB\Select::crossUpdateFromSelect方法的典型用法代码示例。如果您正苦于以下问题:PHP Select::crossUpdateFromSelect方法的具体用法?PHP Select::crossUpdateFromSelect怎么用?PHP Select::crossUpdateFromSelect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\DB\Select
的用法示例。
在下文中一共展示了Select::crossUpdateFromSelect方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}