コード例 #1
0
ファイル: Status.php プロジェクト: Atlis/docker-magento2
 /**
  * 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)
 {
     if ($this->_catalogInventoryData->isShowOutOfStock()) {
         return $this;
     }
     $resource = $this->_getResource();
     $resource->prepareCatalogProductIndexSelect($select, $entityField, $websiteField);
     return $this;
 }
コード例 #2
0
ファイル: CreditmemoLoader.php プロジェクト: aiesh/magento2
 /**
  * Initialize creditmemo model instance
  *
  * @return \Magento\Sales\Model\Order\Creditmemo|false
  */
 public function load()
 {
     $creditmemo = false;
     $creditmemoId = $this->getCreditmemoId();
     $orderId = $this->getOrderId();
     if ($creditmemoId) {
         $creditmemo = $this->creditmemoFactory->create()->load($creditmemoId);
     } elseif ($orderId) {
         $data = $this->getCreditmemo();
         $order = $this->orderFactory->create()->load($orderId);
         $invoice = $this->_initInvoice($order);
         if (!$this->_canCreditmemo($order)) {
             return false;
         }
         $savedData = $this->_getItemData();
         $qtys = array();
         $backToStock = array();
         foreach ($savedData as $orderItemId => $itemData) {
             if (isset($itemData['qty'])) {
                 $qtys[$orderItemId] = $itemData['qty'];
             }
             if (isset($itemData['back_to_stock'])) {
                 $backToStock[$orderItemId] = true;
             }
         }
         $data['qtys'] = $qtys;
         $service = $this->orderServiceFactory->create(array('order' => $order));
         if ($invoice) {
             $creditmemo = $service->prepareInvoiceCreditmemo($invoice, $data);
         } else {
             $creditmemo = $service->prepareCreditmemo($data);
         }
         /**
          * Process back to stock flags
          */
         foreach ($creditmemo->getAllItems() as $creditmemoItem) {
             $orderItem = $creditmemoItem->getOrderItem();
             $parentId = $orderItem->getParentItemId();
             if (isset($backToStock[$orderItem->getId()])) {
                 $creditmemoItem->setBackToStock(true);
             } elseif ($orderItem->getParentItem() && isset($backToStock[$parentId]) && $backToStock[$parentId]) {
                 $creditmemoItem->setBackToStock(true);
             } elseif (empty($savedData)) {
                 $creditmemoItem->setBackToStock($this->inventoryHelper->isAutoReturnEnabled());
             } else {
                 $creditmemoItem->setBackToStock(false);
             }
         }
     }
     $this->eventManager->dispatch('adminhtml_sales_order_creditmemo_register_before', array('creditmemo' => $creditmemo, 'input' => $this->getCreditmemo()));
     $this->registry->register('current_creditmemo', $creditmemo);
     return $creditmemo;
 }
コード例 #3
0
 public function testExecuteThatProductIdsAreObtainedFromAttributeHelper()
 {
     $this->attributeHelper->expects($this->any())->method('getProductIds')->will($this->returnValue([5]));
     $this->attributeHelper->expects($this->any())->method('getSelectedStoreId')->will($this->returnValue([1]));
     $this->inventoryHelper->expects($this->any())->method('getConfigItemOptions')->will($this->returnValue([]));
     $this->product->expects($this->any())->method('isProductsHasSku')->with([5])->will($this->returnValue(true));
     $this->stockItemService->expects($this->any())->method('getStockItem')->with(5)->will($this->returnValue($this->stockItem));
     $this->stockIndexerProcessor->expects($this->any())->method('reindexList')->with([5]);
     $this->request->expects($this->any())->method('getParam')->will($this->returnValueMap([['inventory', [], [7]]]));
     $this->messageManager->expects($this->never())->method('addError');
     $this->messageManager->expects($this->never())->method('addException');
     $this->object->execute();
 }
コード例 #4
0
ファイル: Collection.php プロジェクト: aiesh/magento2
 /**
  * Add products to items and item options
  *
  * @return $this
  */
 protected function _assignProducts()
 {
     \Magento\Framework\Profiler::start('WISHLIST:' . __METHOD__, array('group' => 'WISHLIST', 'method' => __METHOD__));
     $productIds = array();
     $this->_productIds = array_merge($this->_productIds, array_keys($productIds));
     $attributes = $this->_wishlistConfig->getProductAttributes();
     /** @var \Magento\Catalog\Model\Resource\Product\Collection $productCollection */
     $productCollection = $this->_productCollectionFactory->create();
     if ($this->_productVisible) {
         $productCollection->setVisibility($this->_productVisibility->getVisibleInSiteIds());
     }
     $productCollection->addPriceData()->addTaxPercents()->addIdFilter($this->_productIds)->addAttributeToSelect($attributes)->addOptionsToResult()->addUrlRewrite();
     if ($this->_productSalable) {
         $productCollection = $this->_adminhtmlSales->applySalableProductTypesFilter($productCollection);
     }
     $this->_eventManager->dispatch('wishlist_item_collection_products_after_load', array('product_collection' => $productCollection));
     $checkInStock = $this->_productInStock && !$this->_inventoryData->isShowOutOfStock();
     foreach ($this as $item) {
         $product = $productCollection->getItemById($item->getProductId());
         if ($product) {
             if ($checkInStock && !$product->isInStock()) {
                 $this->removeItemByKey($item->getId());
             } else {
                 $product->setCustomOptions(array());
                 $item->setProduct($product);
                 $item->setProductName($product->getName());
                 $item->setName($product->getName());
                 $item->setPrice($product->getPrice());
             }
         } else {
             $item->isDeleted(true);
         }
     }
     \Magento\Framework\Profiler::stop('WISHLIST:' . __METHOD__);
     return $this;
 }
コード例 #5
0
ファイル: Observer.php プロジェクト: Atlis/docker-magento2
 /**
  * Detects whether product status should be shown
  *
  * @param EventObserver $observer
  * @return $this
  */
 public function displayProductStatusInfo($observer)
 {
     $info = $observer->getEvent()->getStatus();
     $info->setDisplayStatus($this->_catalogInventoryData->isDisplayProductStockStatus());
     return $this;
 }
コード例 #6
0
 public function testIsDisplayProductStockStatus()
 {
     $this->scopeConfigMock->expects($this->once())->method('isSetFlag')->with($this->equalTo(Data::XML_PATH_DISPLAY_PRODUCT_STOCK_STATUS), $this->equalTo(\Magento\Store\Model\ScopeInterface::SCOPE_STORE))->will($this->returnValue(true));
     $this->assertTrue($this->data->isDisplayProductStockStatus());
 }