本文整理汇总了PHP中Magento\CatalogInventory\Api\StockConfigurationInterface类的典型用法代码示例。如果您正苦于以下问题:PHP StockConfigurationInterface类的具体用法?PHP StockConfigurationInterface怎么用?PHP StockConfigurationInterface使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了StockConfigurationInterface类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: execute
/**
* Return creditmemo items qty to stock
*
* @param EventObserver $observer
* @return void
*/
public function execute(EventObserver $observer)
{
/* @var $creditmemo \Magento\Sales\Model\Order\Creditmemo */
$creditmemo = $observer->getEvent()->getCreditmemo();
$itemsToUpdate = [];
foreach ($creditmemo->getAllItems() as $item) {
$qty = $item->getQty();
if ($item->getBackToStock() && $qty || $this->stockConfiguration->isAutoReturnEnabled()) {
$productId = $item->getProductId();
$parentItemId = $item->getOrderItem()->getParentItemId();
/* @var $parentItem \Magento\Sales\Model\Order\Creditmemo\Item */
$parentItem = $parentItemId ? $creditmemo->getItemByOrderId($parentItemId) : false;
$qty = $parentItem ? $parentItem->getQty() * $qty : $qty;
if (isset($itemsToUpdate[$productId])) {
$itemsToUpdate[$productId] += $qty;
} else {
$itemsToUpdate[$productId] = $qty;
}
}
}
if (!empty($itemsToUpdate)) {
$this->stockManagement->revertProductsSale($itemsToUpdate, $creditmemo->getStore()->getWebsiteId());
$updatedItemIds = array_keys($itemsToUpdate);
$this->stockIndexerProcessor->reindexList($updatedItemIds);
$this->priceIndexer->reindexList($updatedItemIds);
}
}
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:33,代码来源:RefundOrderInventoryObserver.php
示例2: loadInventoryData
/**
* Load inventory data for a list of product ids and a given store.
*
* @param integer $storeId Store id.
* @param array $productIds Product ids list.
*
* @return array
*/
public function loadInventoryData($storeId, $productIds)
{
$websiteId = $this->getWebsiteId($storeId);
$stockId = $this->getStockId($websiteId);
$select = $this->getConnection()->select()->from(['ciss' => $this->getTable('cataloginventory_stock_status')], ['product_id', 'stock_status', 'qty'])->where('ciss.stock_id = ?', $stockId)->where('ciss.website_id = ?', $this->stockConfiguration->getDefaultScopeId())->where('ciss.product_id IN(?)', $productIds);
return $this->getConnection()->fetchAll($select);
}
开发者ID:smile-sa,项目名称:elasticsuite,代码行数:15,代码来源:InventoryData.php
示例3: aroundRegisterProductsSale
/**
* Update stock item on the stock and distribute qty by lots.
*
* @param \Magento\CatalogInventory\Model\StockManagement $subject
* @param \Closure $proceed
* @param array $items
* @param int $websiteId is not used
* @throws \Magento\Framework\Exception\LocalizedException
* @return null
*/
public function aroundRegisterProductsSale(\Magento\CatalogInventory\Model\StockManagement $subject, \Closure $proceed, array $items, $websiteId)
{
/* This code is moved from original 'registerProductsSale' method. */
/* replace websiteId by stockId */
$stockId = $this->_manStock->getCurrentStockId();
$def = $this->_manTrans->begin();
$lockedItems = $this->_resourceStock->lockProductsStock(array_keys($items), $stockId);
$fullSaveItems = $registeredItems = [];
foreach ($lockedItems as $lockedItemRecord) {
$productId = $lockedItemRecord['product_id'];
$orderedQty = $items[$productId];
/** @var \Magento\CatalogInventory\Api\Data\StockItemInterface $stockItem */
$stockItem = $this->_providerStockRegistry->getStockItem($productId, $stockId);
$stockItemId = $stockItem->getItemId();
$canSubtractQty = $stockItemId && $this->_canSubtractQty($stockItem);
if (!$canSubtractQty || !$this->_configStock->isQty($lockedItemRecord['type_id'])) {
continue;
}
if (!$stockItem->hasAdminArea() && !$this->_stockState->checkQty($productId, $orderedQty)) {
$this->_manTrans->rollback($def);
throw new \Magento\Framework\Exception\LocalizedException(__('Not all of your products are available in the requested quantity.'));
}
if ($this->_canSubtractQty($stockItem)) {
$stockItem->setQty($stockItem->getQty() - $orderedQty);
}
$registeredItems[$productId] = $orderedQty;
if (!$this->_stockState->verifyStock($productId) || $this->_stockState->verifyNotification($productId)) {
$fullSaveItems[] = $stockItem;
}
}
$this->_resourceStock->correctItemsQty($registeredItems, $stockId, '-');
$this->_manTrans->commit($def);
return $fullSaveItems;
}
开发者ID:praxigento,项目名称:mobi_mod_mage2_warehouse,代码行数:44,代码来源:StockManagement.php
示例4: modifyData
/**
* {@inheritdoc}
*/
public function modifyData(array $data)
{
$fieldCode = 'quantity_and_stock_status';
$model = $this->locator->getProduct();
$modelId = $model->getId();
/** @var StockItemInterface $stockItem */
$stockItem = $this->stockRegistry->getStockItem($modelId, $model->getStore()->getWebsiteId());
$stockData = $modelId ? $this->getData($stockItem) : [];
if (!empty($stockData)) {
$data[$modelId][self::DATA_SOURCE_DEFAULT][self::STOCK_DATA_FIELDS] = $stockData;
}
if (isset($stockData['is_in_stock'])) {
$data[$modelId][self::DATA_SOURCE_DEFAULT][$fieldCode]['is_in_stock'] = (int) $stockData['is_in_stock'];
}
if (!empty($this->stockConfiguration->getDefaultConfigValue(StockItemInterface::MIN_SALE_QTY))) {
$minSaleQtyData = null;
$defaultConfigValue = $this->stockConfiguration->getDefaultConfigValue(StockItemInterface::MIN_SALE_QTY);
if (strpos($defaultConfigValue, 'a:') === 0) {
// Set data source for dynamicRows Minimum Qty Allowed in Shopping Cart
$minSaleQtyValue = unserialize($defaultConfigValue);
foreach ($minSaleQtyValue as $group => $qty) {
$minSaleQtyData[] = [StockItemInterface::CUSTOMER_GROUP_ID => $group, StockItemInterface::MIN_SALE_QTY => $qty];
}
} else {
$minSaleQtyData = $defaultConfigValue;
}
$path = $modelId . '/' . self::DATA_SOURCE_DEFAULT . '/stock_data/min_qty_allowed_in_shopping_cart';
$data = $this->arrayManager->set($path, $data, $minSaleQtyData);
}
return $data;
}
开发者ID:Doability,项目名称:magento2dev,代码行数:34,代码来源:AdvancedInventory.php
示例5: testAssignStatusToProduct
public function testAssignStatusToProduct()
{
$websiteId = 1;
$status = 'test';
$stockStatusMock = $this->getMockBuilder('Magento\\CatalogInventory\\Api\\Data\\StockStatusInterface')->disableOriginalConstructor()->getMock();
$stockStatusMock->expects($this->any())->method('getStockStatus')->willReturn($status);
$this->stockRegistryProviderMock->expects($this->any())->method('getStockStatus')->willReturn($stockStatusMock);
$this->stockConfiguration->expects($this->once())->method('getDefaultScopeId')->willReturn($websiteId);
$productMock = $this->getMockBuilder('Magento\\Catalog\\Model\\Product')->disableOriginalConstructor()->setMethods(['setIsSalable', 'getId'])->getMock();
$productMock->expects($this->once())->method('setIsSalable')->with($status);
$this->assertNull($this->stock->assignStatusToProduct($productMock));
}
开发者ID:Doability,项目名称:magento2dev,代码行数:12,代码来源:StockTest.php
示例6: _assignProducts
/**
* Add products to items and item options
*
* @return $this
*/
protected function _assignProducts()
{
\Magento\Framework\Profiler::start('WISHLIST:' . __METHOD__, ['group' => 'WISHLIST', 'method' => __METHOD__]);
$productIds = [];
$this->_productIds = array_merge($this->_productIds, array_keys($productIds));
/** @var \Magento\Catalog\Model\ResourceModel\Product\Collection $productCollection */
$productCollection = $this->_productCollectionFactory->create();
if ($this->_productVisible) {
$productCollection->setVisibility($this->_productVisibility->getVisibleInSiteIds());
}
$productCollection->addPriceData()->addTaxPercents()->addIdFilter($this->_productIds)->addAttributeToSelect('*')->addOptionsToResult()->addUrlRewrite();
if ($this->_productSalable) {
$productCollection = $this->_adminhtmlSales->applySalableProductTypesFilter($productCollection);
}
$this->_eventManager->dispatch('wishlist_item_collection_products_after_load', ['product_collection' => $productCollection]);
$checkInStock = $this->_productInStock && !$this->stockConfiguration->isShowOutOfStock();
foreach ($this as $item) {
$product = $productCollection->getItemById($item->getProductId());
if ($product) {
if ($checkInStock && !$product->isInStock()) {
$this->removeItemByKey($item->getId());
} else {
$product->setCustomOptions([]);
$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;
}
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:40,代码来源:Collection.php
示例7: testGenerateSimpleProducts
/**
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
public function testGenerateSimpleProducts()
{
$productsData = [6 => ['image' => 'image.jpg', 'name' => 'config-red', 'configurable_attribute' => '{"new_attr":"6"}', 'sku' => 'config-red', 'quantity_and_stock_status' => ['qty' => ''], 'weight' => '333']];
$stockData = ['manage_stock' => '0', 'use_config_enable_qty_increments' => '1', 'use_config_qty_increments' => '1', 'use_config_manage_stock' => 0, 'is_decimal_divided' => 0];
$parentProductMock = $this->getMockBuilder('\\Magento\\Catalog\\Model\\Product')->setMethods(['__wakeup', 'getNewVariationsAttributeSetId', 'getStockData', 'getQuantityAndStockStatus', 'getWebsiteIds'])->disableOriginalConstructor()->getMock();
$newSimpleProductMock = $this->getMockBuilder('\\Magento\\Catalog\\Model\\Product')->setMethods(['__wakeup', 'save', 'getId', 'setStoreId', 'setTypeId', 'setAttributeSetId', 'getTypeInstance', 'getStoreId', 'addData', 'setWebsiteIds', 'setStatus', 'setVisibility'])->disableOriginalConstructor()->getMock();
$productTypeMock = $this->getMockBuilder('Magento\\Catalog\\Model\\Product\\Type')->setMethods(['getSetAttributes'])->disableOriginalConstructor()->getMock();
$editableAttributeMock = $this->getMockBuilder('Magento\\Eav\\Model\\Entity\\Attribute')->setMethods(['getIsUnique', 'getAttributeCode', 'getFrontend', 'getIsVisible'])->disableOriginalConstructor()->getMock();
$frontendAttributeMock = $this->getMockBuilder('Magento\\Eav\\Model\\Entity\\Attribute\\Frontend')->setMethods(['getInputType'])->disableOriginalConstructor()->getMock();
$parentProductMock->expects($this->once())->method('getNewVariationsAttributeSetId')->willReturn('new_attr_set_id');
$this->productFactoryMock->expects($this->once())->method('create')->willReturn($newSimpleProductMock);
$newSimpleProductMock->expects($this->once())->method('setStoreId')->with(0)->willReturnSelf();
$newSimpleProductMock->expects($this->once())->method('setTypeId')->with('simple')->willReturnSelf();
$newSimpleProductMock->expects($this->once())->method('setAttributeSetId')->with('new_attr_set_id')->willReturnSelf();
$newSimpleProductMock->expects($this->once())->method('getTypeInstance')->willReturn($productTypeMock);
$productTypeMock->expects($this->once())->method('getSetAttributes')->with($newSimpleProductMock)->willReturn([$editableAttributeMock]);
$editableAttributeMock->expects($this->once())->method('getIsUnique')->willReturn(false);
$editableAttributeMock->expects($this->once())->method('getAttributeCode')->willReturn('some_code');
$editableAttributeMock->expects($this->any())->method('getFrontend')->willReturn($frontendAttributeMock);
$frontendAttributeMock->expects($this->any())->method('getInputType')->willReturn('input_type');
$editableAttributeMock->expects($this->any())->method('getIsVisible')->willReturn(false);
$parentProductMock->expects($this->once())->method('getStockData')->willReturn($stockData);
$parentProductMock->expects($this->once())->method('getQuantityAndStockStatus')->willReturn(['is_in_stock' => 1]);
$newSimpleProductMock->expects($this->once())->method('getStoreId')->willReturn('store_id');
$this->stockConfiguration->expects($this->once())->method('getManageStock')->with('store_id')->willReturn(1);
$newSimpleProductMock->expects($this->once())->method('addData')->willReturnSelf();
$parentProductMock->expects($this->once())->method('getWebsiteIds')->willReturn('website_id');
$newSimpleProductMock->expects($this->once())->method('setWebsiteIds')->with('website_id')->willReturnSelf();
$newSimpleProductMock->expects($this->once())->method('setVisibility')->with(1)->willReturnSelf();
$newSimpleProductMock->expects($this->once())->method('save')->willReturnSelf();
$newSimpleProductMock->expects($this->once())->method('getId')->willReturn('product_id');
$this->assertEquals(['product_id'], $this->model->generateSimpleProducts($parentProductMock, $productsData));
}
开发者ID:rafaelstz,项目名称:magento2,代码行数:36,代码来源:VariationHandlerTest.php
示例8: testGetDefaultConfigValue
/**
* Run test getDefaultConfigValue method
*
* @return void
*/
public function testGetDefaultConfigValue()
{
$field = 'filed-name';
$this->stockConfigurationMock->expects($this->once())->method('getDefaultConfigValue')->will($this->returnValue('return-value'));
$result = $this->inventory->getDefaultConfigValue($field);
$this->assertEquals('return-value', $result);
}
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:12,代码来源:InventoryTest.php
示例9: useNotifyStockQtyFilter
/**
* Add Notify Stock Qty Condition to collection
*
* @param null|int $storeId
* @return $this
*/
public function useNotifyStockQtyFilter($storeId = null)
{
$this->joinInventoryItem(['qty']);
$notifyStockExpr = $this->getConnection()->getCheckSql($this->_getInventoryItemField('use_config_notify_stock_qty') . ' = 1', (int) $this->stockConfiguration->getNotifyStockQty($storeId), $this->_getInventoryItemField('notify_stock_qty'));
$this->getSelect()->where($this->_getInventoryItemField('qty') . ' < ?', $notifyStockExpr);
return $this;
}
开发者ID:nja78,项目名称:magento2,代码行数:13,代码来源:Collection.php
示例10: getProductStockStatusBySku
/**
* @param string $productSku
* @param null $websiteId
* @return int
* @throws \Magento\Framework\Exception\NoSuchEntityException
*/
public function getProductStockStatusBySku($productSku, $websiteId = null)
{
//if (!$websiteId) {
$websiteId = $this->stockConfiguration->getDefaultWebsiteId();
//}
$productId = $this->resolveProductId($productSku);
return $this->getProductStockStatus($productId, $websiteId);
}
开发者ID:shabbirvividads,项目名称:magento2,代码行数:14,代码来源:StockRegistry.php
示例11: checkQuoteItemQty
/**
* @param int $productId
* @param float $itemQty
* @param float $qtyToCheck
* @param float $origQty
* @param int $scopeId
* @return int
*/
public function checkQuoteItemQty($productId, $itemQty, $qtyToCheck, $origQty, $scopeId = null)
{
if ($scopeId === null) {
$scopeId = $this->stockConfiguration->getDefaultScopeId();
}
$stockItem = $this->stockRegistryProvider->getStockItem($productId, $scopeId);
return $this->stockStateProvider->checkQuoteItemQty($stockItem, $itemQty, $qtyToCheck, $origQty);
}
开发者ID:BlackIkeEagle,项目名称:magento2-continuousphp,代码行数:16,代码来源:StockState.php
示例12: testReindexEntity
/**
* @magentoDataFixture Magento/Store/_files/website.php
* @magentoDataFixture Magento/Catalog/_files/product_simple.php
*
* @throws \Magento\Framework\Exception\NoSuchEntityException
*/
public function testReindexEntity()
{
/** @var \Magento\Catalog\Model\ProductRepository $productRepository */
$productRepository = $this->getObject(\Magento\Catalog\Model\ProductRepository::class);
/** @var \Magento\Store\Api\WebsiteRepositoryInterface $websiteRepository */
$websiteRepository = $this->getObject(\Magento\Store\Api\WebsiteRepositoryInterface::class);
$product = $productRepository->get('simple');
$testWebsite = $websiteRepository->get('test');
$product->setWebsiteIds([1, $testWebsite->getId()])->save();
/** @var \Magento\CatalogInventory\Api\StockStatusCriteriaInterfaceFactory $criteriaFactory */
$criteriaFactory = $this->getObject(\Magento\CatalogInventory\Api\StockStatusCriteriaInterfaceFactory::class);
/** @var \Magento\CatalogInventory\Api\StockStatusRepositoryInterface $stockStatusRepository */
$stockStatusRepository = $this->getObject(\Magento\CatalogInventory\Api\StockStatusRepositoryInterface::class);
$criteria = $criteriaFactory->create();
$criteria->setProductsFilter([$product->getId()]);
$criteria->addFilter('website', 'website_id', $this->stockConfiguration->getDefaultScopeId());
$items = $stockStatusRepository->getList($criteria)->getItems();
$this->assertEquals($product->getId(), $items[$product->getId()]->getProductId());
}
开发者ID:Doability,项目名称:magento2dev,代码行数:25,代码来源:DefaultStockTest.php
示例13: testSetMinQty
/**
* @param bool $useConfigMinQty
* @param float $minQty
* @dataProvider setMinQtyDataProvider
*/
public function testSetMinQty($useConfigMinQty, $minQty)
{
$this->setDataArrayValue('use_config_min_qty', $useConfigMinQty);
if ($useConfigMinQty) {
$this->stockConfiguration->expects($this->any())->method('getMinQty')->will($this->returnValue($minQty));
} else {
$this->setDataArrayValue('min_qty', $minQty);
}
$this->assertSame($minQty, $this->item->getMinQty());
}
开发者ID:opexsw,项目名称:magento2,代码行数:15,代码来源:ItemTest.php
示例14: filter
/**
* Filter stock data
*
* @param array $stockData
* @return array
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
public function filter(array $stockData)
{
if (!isset($stockData['use_config_manage_stock'])) {
$stockData['use_config_manage_stock'] = 0;
}
if ($stockData['use_config_manage_stock'] == 1 && !isset($stockData['manage_stock'])) {
$stockData['manage_stock'] = $this->stockConfiguration->getManageStock();
}
if (isset($stockData['qty']) && (double) $stockData['qty'] > self::MAX_QTY_VALUE) {
$stockData['qty'] = self::MAX_QTY_VALUE;
}
if (isset($stockData['min_qty']) && (int) $stockData['min_qty'] < 0) {
$stockData['min_qty'] = 0;
}
if (!isset($stockData['is_decimal_divided']) || $stockData['is_qty_decimal'] == 0) {
$stockData['is_decimal_divided'] = 0;
}
return $stockData;
}
开发者ID:Doability,项目名称:magento2dev,代码行数:26,代码来源:StockDataFilter.php
示例15: _initConfig
/**
* Load some inventory configuration settings
*
* @return void
*/
protected function _initConfig()
{
if (!$this->_isConfig) {
$configMap = ['_isConfigManageStock' => \Magento\CatalogInventory\Model\Configuration::XML_PATH_MANAGE_STOCK, '_isConfigBackorders' => \Magento\CatalogInventory\Model\Configuration::XML_PATH_BACKORDERS, '_configMinQty' => \Magento\CatalogInventory\Model\Configuration::XML_PATH_MIN_QTY, '_configNotifyStockQty' => \Magento\CatalogInventory\Model\Configuration::XML_PATH_NOTIFY_STOCK_QTY];
foreach ($configMap as $field => $const) {
$this->{$field} = (int) $this->_scopeConfig->getValue($const, \Magento\Store\Model\ScopeInterface::SCOPE_STORE);
}
$this->_isConfig = true;
$this->_configTypeIds = array_keys($this->stockConfiguration->getIsQtyTypeIds(true));
}
}
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:16,代码来源:Stock.php
示例16: load
/**
* Initialize creditmemo model instance
*
* @return \Magento\Sales\Model\Order\Creditmemo|false
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
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 = [];
$backToStock = [];
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(['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->stockConfiguration->isAutoReturnEnabled());
} else {
$creditmemoItem->setBackToStock(false);
}
}
}
$this->eventManager->dispatch('adminhtml_sales_order_creditmemo_register_before', ['creditmemo' => $creditmemo, 'input' => $this->getCreditmemo()]);
$this->registry->register('current_creditmemo', $creditmemo);
return $creditmemo;
}
开发者ID:nja78,项目名称:magento2,代码行数:59,代码来源:CreditmemoLoader.php
示例17: testGetQtyIncrements
/**
* @param array $config
* @param mixed $expected
* @dataProvider getQtyIncrementsDataProvider(
*/
public function testGetQtyIncrements($config, $expected)
{
$this->setDataArrayValue('qty_increments', $config['qty_increments']);
$this->setDataArrayValue('enable_qty_increments', $config['enable_qty_increments']);
$this->setDataArrayValue('use_config_qty_increments', $config['use_config_qty_increments']);
if ($config['use_config_qty_increments']) {
$this->stockConfiguration->expects($this->once())->method('getQtyIncrements')->with($this->storeId)->willReturn($config['qty_increments']);
} else {
$this->setDataArrayValue('qty_increments', $config['qty_increments']);
}
$this->assertEquals($expected, $this->item->getQtyIncrements());
}
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:17,代码来源:ItemTest.php
示例18: testModifyData
public function testModifyData()
{
$modelId = 1;
$someData = 1;
$this->productMock->expects($this->any())->method('getId')->willReturn($modelId);
$this->stockConfigurationMock->expects($this->any())->method('getDefaultConfigValue')->willReturn("a:0:{}");
$this->stockItemMock->expects($this->once())->method('getData')->willReturn(['someData']);
$this->stockItemMock->expects($this->once())->method('getManageStock')->willReturn($someData);
$this->stockItemMock->expects($this->once())->method('getQty')->willReturn($someData);
$this->stockItemMock->expects($this->once())->method('getMinQty')->willReturn($someData);
$this->stockItemMock->expects($this->once())->method('getMinSaleQty')->willReturn($someData);
$this->stockItemMock->expects($this->once())->method('getMaxSaleQty')->willReturn($someData);
$this->stockItemMock->expects($this->once())->method('getIsQtyDecimal')->willReturn($someData);
$this->stockItemMock->expects($this->once())->method('getIsDecimalDivided')->willReturn($someData);
$this->stockItemMock->expects($this->once())->method('getBackorders')->willReturn($someData);
$this->stockItemMock->expects($this->once())->method('getNotifyStockQty')->willReturn($someData);
$this->stockItemMock->expects($this->once())->method('getEnableQtyIncrements')->willReturn($someData);
$this->stockItemMock->expects($this->once())->method('getQtyIncrements')->willReturn($someData);
$this->stockItemMock->expects($this->once())->method('getIsInStock')->willReturn($someData);
$this->arrayManagerMock->expects($this->once())->method('set')->with('1/product/stock_data/min_qty_allowed_in_shopping_cart')->willReturnArgument(1);
$this->assertArrayHasKey($modelId, $this->getModel()->modifyData([]));
}
开发者ID:Doability,项目名称:magento2dev,代码行数:22,代码来源:AdvancedInventoryTest.php
示例19: updateLowStockDate
/**
* Update items low stock date basing on their quantities and config settings
*
* @param int|string $website
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
* @return void
*/
public function updateLowStockDate($website)
{
$websiteId = $this->stockConfiguration->getDefaultScopeId();
$this->_initConfig();
$connection = $this->getConnection();
$condition = $connection->quoteInto('(use_config_notify_stock_qty = 1 AND qty < ?)', $this->_configNotifyStockQty) . ' OR (use_config_notify_stock_qty = 0 AND qty < notify_stock_qty)';
$currentDbTime = $connection->quoteInto('?', $this->dateTime->gmtDate());
$conditionalDate = $connection->getCheckSql($condition, $currentDbTime, 'NULL');
$value = ['low_stock_date' => new \Zend_Db_Expr($conditionalDate)];
$select = $connection->select()->from($this->getTable('catalog_product_entity'), 'entity_id')->where('type_id IN(?)', $this->_configTypeIds);
$where = sprintf('website_id = %1$d' . ' AND ((use_config_manage_stock = 1 AND 1 = %2$d) OR (use_config_manage_stock = 0 AND manage_stock = 1))' . ' AND product_id IN (%3$s)', $websiteId, $this->_isConfigManageStock, $select->assemble());
$connection->update($this->getTable('cataloginventory_stock_item'), $value, $where);
}
开发者ID:Doability,项目名称:magento2dev,代码行数:20,代码来源:Stock.php
示例20: saveStockItemData
/**
* Prepare stock item data for save
*
* @param \Magento\Catalog\Model\Product $product
* @return $this
*/
protected function saveStockItemData($product)
{
$stockItemData = $product->getStockData();
$stockItemData['product_id'] = $product->getId();
if (!isset($stockItemData['website_id'])) {
$stockItemData['website_id'] = $this->stockConfiguration->getDefaultScopeId();
}
$stockItemData['stock_id'] = $this->stockRegistry->getStock($stockItemData['website_id'])->getStockId();
foreach ($this->paramListToCheck as $dataKey => $configPath) {
if (null !== $product->getData($configPath['item']) && null === $product->getData($configPath['config'])) {
$stockItemData[$dataKey] = false;
}
}
$originalQty = $product->getData('stock_data/original_inventory_qty');
if (strlen($originalQty) > 0) {
$stockItemData['qty_correction'] = (isset($stockItemData['qty']) ? $stockItemData['qty'] : 0) - $originalQty;
}
// todo resolve issue with builder and identity field name
$stockItem = $this->stockRegistry->getStockItem($stockItemData['product_id'], $stockItemData['website_id']);
$stockItem->addData($stockItemData);
$this->stockItemRepository->save($stockItem);
return $this;
}
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:29,代码来源:SaveInventoryDataObserver.php
注:本文中的Magento\CatalogInventory\Api\StockConfigurationInterface类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论