Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions
BackOrderCondition Class Reference
Inheritance diagram for BackOrderCondition:
IsProductSalableForRequestedQtyInterface

Public Member Functions

 __construct (IsProductSalableBackOrderCondition $backOrderCondition, ProductSalabilityErrorInterfaceFactory $productSalabilityErrorFactory, ProductSalableResultInterfaceFactory $productSalableResultFactory)
 
 execute (string $sku, int $stockId, float $requestedQty)
 

Detailed Description

Definition at line 19 of file BackOrderCondition.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( IsProductSalableBackOrderCondition  $backOrderCondition,
ProductSalabilityErrorInterfaceFactory  $productSalabilityErrorFactory,
ProductSalableResultInterfaceFactory  $productSalableResultFactory 
)
Parameters
IsProductSalableBackOrderCondition$backOrderCondition
ProductSalabilityErrorInterfaceFactory$productSalabilityErrorFactory
ProductSalableResultInterfaceFactory$productSalableResultFactory

Definition at line 41 of file BackOrderCondition.php.

45  {
46  $this->backOrderCondition = $backOrderCondition;
47  $this->productSalabilityErrorFactory = $productSalabilityErrorFactory;
48  $this->productSalableResultFactory = $productSalableResultFactory;
49  }

Member Function Documentation

◆ execute()

execute ( string  $sku,
int  $stockId,
float  $requestedQty 
)

Get is product salable for given SKU in a given Stock for a certain Qty

Parameters
string$sku
int$stockId
float$requestedQty
Returns
\Magento\InventorySalesApi\Api\Data\ProductSalableResultInterface
Exceptions
@SuppressWarnings(PHPMD.UnusedFormalParameter)

Implements IsProductSalableForRequestedQtyInterface.

Definition at line 55 of file BackOrderCondition.php.

55  : ProductSalableResultInterface
56  {
57  $isValid = $this->backOrderCondition->execute($sku, $stockId);
58  if (!$isValid) {
59  $errors = [
60  $this->productSalabilityErrorFactory->create([
61  'code' => 'back_order-disabled',
62  'message' => __('Backorders are disabled')
63  ])
64  ];
65  return $this->productSalableResultFactory->create(['errors' => $errors]);
66  }
67 
68  return $this->productSalableResultFactory->create(['errors' => []]);
69  }
__()
Definition: __.php:13
$errors
Definition: overview.phtml:9

The documentation for this class was generated from the following file: