本文整理汇总了PHP中Magento\Catalog\Model\ResourceModel\Product\Collection::joinTable方法的典型用法代码示例。如果您正苦于以下问题:PHP Collection::joinTable方法的具体用法?PHP Collection::joinTable怎么用?PHP Collection::joinTable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Catalog\Model\ResourceModel\Product\Collection
的用法示例。
在下文中一共展示了Collection::joinTable方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addLowStockFilter
/**
* Add low stock filter to product collection
*
* @param \Magento\Catalog\Model\ResourceModel\Product\Collection $collection
* @param array $fields
* @return $this
*/
public function addLowStockFilter(\Magento\Catalog\Model\ResourceModel\Product\Collection $collection, $fields)
{
$this->_initConfig();
$connection = $collection->getSelect()->getConnection();
$qtyIf = $connection->getCheckSql('invtr.use_config_notify_stock_qty > 0', $this->_configNotifyStockQty, 'invtr.notify_stock_qty');
$conditions = [[$connection->prepareSqlCondition('invtr.use_config_manage_stock', 1), $connection->prepareSqlCondition($this->_isConfigManageStock, 1), $connection->prepareSqlCondition('invtr.qty', ['lt' => $qtyIf])], [$connection->prepareSqlCondition('invtr.use_config_manage_stock', 0), $connection->prepareSqlCondition('invtr.manage_stock', 1)]];
$where = [];
foreach ($conditions as $k => $part) {
$where[$k] = join(' ' . \Magento\Framework\DB\Select::SQL_AND . ' ', $part);
}
$where = $connection->prepareSqlCondition('invtr.low_stock_date', ['notnull' => true]) . ' ' . \Magento\Framework\DB\Select::SQL_AND . ' ((' . join(') ' . \Magento\Framework\DB\Select::SQL_OR . ' (', $where) . '))';
$collection->joinTable(['invtr' => 'cataloginventory_stock_item'], 'product_id = entity_id', $fields, $where);
return $this;
}