當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Collection::joinTable方法代碼示例

本文整理匯總了PHP中Magento\Catalog\Model\Resource\Product\Collection::joinTable方法的典型用法代碼示例。如果您正苦於以下問題:PHP Collection::joinTable方法的具體用法?PHP Collection::joinTable怎麽用?PHP Collection::joinTable使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Magento\Catalog\Model\Resource\Product\Collection的用法示例。


在下文中一共展示了Collection::joinTable方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: addCatalogInventoryToProductCollection

 /**
  * Add join for catalog in stock field to product collection
  *
  * @param \Magento\Catalog\Model\Resource\Product\Collection $productCollection
  * @param array $columns
  * @return $this
  */
 public function addCatalogInventoryToProductCollection($productCollection, $columns = null)
 {
     if ($columns === null) {
         $adapter = $this->_getReadAdapter();
         $isManageStock = (int) $this->_scopeConfig->getValue(\Magento\CatalogInventory\Model\Stock\Item::XML_PATH_MANAGE_STOCK, \Magento\Store\Model\ScopeInterface::SCOPE_STORE);
         $stockExpr = $adapter->getCheckSql('cisi.use_config_manage_stock = 1', $isManageStock, 'cisi.manage_stock');
         $stockExpr = $adapter->getCheckSql("({$stockExpr} = 1)", 'cisi.is_in_stock', '1');
         $columns = array('is_saleable' => new \Zend_Db_Expr($stockExpr), 'inventory_in_stock' => 'is_in_stock');
     }
     $productCollection->joinTable(array('cisi' => 'cataloginventory_stock_item'), 'product_id=entity_id', $columns, null, 'left');
     return $this;
 }
開發者ID:aiesh,項目名稱:magento2,代碼行數:19,代碼來源:Item.php

示例2: addLowStockFilter

 /**
  * Add low stock filter to product collection
  *
  * @param \Magento\Catalog\Model\Resource\Product\Collection $collection
  * @param array $fields
  * @return $this
  */
 public function addLowStockFilter(\Magento\Catalog\Model\Resource\Product\Collection $collection, $fields)
 {
     $this->_initConfig();
     $adapter = $collection->getSelect()->getAdapter();
     $qtyIf = $adapter->getCheckSql('invtr.use_config_notify_stock_qty > 0', $this->_configNotifyStockQty, 'invtr.notify_stock_qty');
     $conditions = [[$adapter->prepareSqlCondition('invtr.use_config_manage_stock', 1), $adapter->prepareSqlCondition($this->_isConfigManageStock, 1), $adapter->prepareSqlCondition('invtr.qty', ['lt' => $qtyIf])], [$adapter->prepareSqlCondition('invtr.use_config_manage_stock', 0), $adapter->prepareSqlCondition('invtr.manage_stock', 1)]];
     $where = [];
     foreach ($conditions as $k => $part) {
         $where[$k] = join(' ' . \Zend_Db_Select::SQL_AND . ' ', $part);
     }
     $where = $adapter->prepareSqlCondition('invtr.low_stock_date', ['notnull' => true]) . ' ' . \Zend_Db_Select::SQL_AND . ' ((' . join(') ' . \Zend_Db_Select::SQL_OR . ' (', $where) . '))';
     $collection->joinTable(['invtr' => 'cataloginventory_stock_item'], 'product_id = entity_id', $fields, $where);
     return $this;
 }
開發者ID:shabbirvividads,項目名稱:magento2,代碼行數:21,代碼來源:Stock.php


注:本文中的Magento\Catalog\Model\Resource\Product\Collection::joinTable方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。