Skip to content

Cleaning up unused code. #33499

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 13 commits into
base: 2.4-develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
* Copyright 2017 Adobe
* All Rights Reserved.
*/
namespace Magento\CatalogInventory\Model;

use Magento\Catalog\Model\CollectionConditionInterface;
use Magento\Eav\Model\Entity\Collection\AbstractCollection;
use Magento\Framework\Data\Collection\AbstractDb;
use Magento\Framework\Data\CollectionModifierInterface;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
* Copyright 2021 Adobe
* All Rights Reserved.
*/

namespace Magento\CatalogInventory\Model\ResourceModel\Stock\Item;

use Magento\CatalogInventory\Api\StockItemCriteriaInterface;
use Magento\Framework\Data\AbstractCriteria;
use Magento\CatalogInventory\Model\ResourceModel\Stock\Item\StockItemCriteriaMapper;

/**
* Class StockItemCriteria
* Class StockItemCriteria Resource model
*/
class StockItemCriteria extends AbstractCriteria implements \Magento\CatalogInventory\Api\StockItemCriteriaInterface
class StockItemCriteria extends AbstractCriteria implements StockItemCriteriaInterface
{
/**
* @param string $mapper
Expand Down Expand Up @@ -80,10 +80,10 @@ public function setQtyFilter($comparisonMethod, $qty)
/**
* Add Criteria object
*
* @param \Magento\CatalogInventory\Api\StockItemCriteriaInterface $criteria
* @param StockItemCriteriaInterface $criteria
* @return bool
*/
public function addCriteria(\Magento\CatalogInventory\Api\StockItemCriteriaInterface $criteria)
public function addCriteria(StockItemCriteriaInterface $criteria)
{
$this->data[self::PART_CRITERIA_LIST]['list'][] = $criteria;
return true;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
* Copyright 2017 Adobe
* All Rights Reserved.
*/

namespace Magento\CatalogInventory\Model\ResourceModel\Stock\Status;

use Magento\CatalogInventory\Api\StockStatusCriteriaInterface;
use Magento\Framework\Data\AbstractCriteria;
use Magento\CatalogInventory\Model\ResourceModel\Stock\Status\StockStatusCriteriaMapper;

/**
* Class StockStatusCriteria
* Class StockStatusCriteria Resource model
*/
class StockStatusCriteria extends AbstractCriteria implements \Magento\CatalogInventory\Api\StockStatusCriteriaInterface
class StockStatusCriteria extends AbstractCriteria implements StockStatusCriteriaInterface
{
/**
* @param string $mapper
Expand All @@ -24,33 +24,45 @@ public function __construct($mapper = '')
}

/**
* @inheritdoc
* Filter by scope(s)
*
* @param int $scope
* @return void
*/
public function setScopeFilter($scope)
{
$this->data['website_filter'] = [$scope];
}

/**
* @inheritdoc
* Add product(s) filter
*
* @param int $products
* @return void
*/
public function setProductsFilter($products)
{
$this->data['products_filter'] = [$products];
}

/**
* @inheritdoc
* Add filter by quantity
*
* @param float $qty
* @return void
*/
public function setQtyFilter($qty)
{
$this->data['qty_filter'] = [$qty];
}

/**
* @inheritdoc
* Add Criteria object
*
* @param \Magento\CatalogInventory\Api\StockStatusCriteriaInterface $criteria
* @return void
*/
public function addCriteria(\Magento\CatalogInventory\Api\StockStatusCriteriaInterface $criteria)
public function addCriteria(StockStatusCriteriaInterface $criteria)
{
$this->data[self::PART_CRITERIA_LIST]['list'][] = $criteria;
}
Expand Down
29 changes: 22 additions & 7 deletions app/code/Magento/CatalogInventory/Model/StockRegistry.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
* Copyright 2017 Adobe
* All Rights Reserved.
*/

namespace Magento\CatalogInventory\Model;
Expand All @@ -15,7 +15,7 @@
use Magento\CatalogInventory\Model\Spi\StockRegistryProviderInterface;

/**
* Class StockRegistry
* Class Catalog StockRegistry
*
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
Expand Down Expand Up @@ -68,6 +68,8 @@ public function __construct(
}

/**
* Get Stock data
*
* @param int $scopeId
* @return \Magento\CatalogInventory\Api\Data\StockInterface
*/
Expand All @@ -78,9 +80,11 @@ public function getStock($scopeId = null)
}

/**
* Get Stock Item data
*
* @param int $productId
* @param int $scopeId
* @return \Magento\CatalogInventory\Api\Data\StockItemInterface
* @return StockItemInterface
*/
public function getStockItem($productId, $scopeId = null)
{
Expand All @@ -89,9 +93,11 @@ public function getStockItem($productId, $scopeId = null)
}

/**
* Get Stock Item By SKU
*
* @param string $productSku
* @param int $scopeId
* @return \Magento\CatalogInventory\Api\Data\StockItemInterface
* @return StockItemInterface
* @throws \Magento\Framework\Exception\NoSuchEntityException
*/
public function getStockItemBySku($productSku, $scopeId = null)
Expand All @@ -102,6 +108,8 @@ public function getStockItemBySku($productSku, $scopeId = null)
}

/**
* Get Stock status
*
* @param int $productId
* @param int $scopeId
* @return \Magento\CatalogInventory\Api\Data\StockStatusInterface
Expand All @@ -113,6 +121,8 @@ public function getStockStatus($productId, $scopeId = null)
}

/**
* Get Stock status by SKU
*
* @param string $productSku
* @param int $scopeId
* @return \Magento\CatalogInventory\Api\Data\StockStatusInterface
Expand All @@ -127,6 +137,7 @@ public function getStockStatusBySku($productSku, $scopeId = null)

/**
* Retrieve Product stock status
*
* @param int $productId
* @param int $scopeId
* @return int
Expand All @@ -139,8 +150,10 @@ public function getProductStockStatus($productId, $scopeId = null)
}

/**
* Get Product Stock status by SKU
*
* @param string $productSku
* @param null $scopeId
* @param null|int $scopeId
* @return int
* @throws \Magento\Framework\Exception\NoSuchEntityException
*/
Expand All @@ -167,7 +180,7 @@ public function getLowStockItems($scopeId, $qty, $currentPage = 1, $pageSize = 0
/**
* @inheritdoc
*/
public function updateStockItemBySku($productSku, \Magento\CatalogInventory\Api\Data\StockItemInterface $stockItem)
public function updateStockItemBySku($productSku, StockItemInterface $stockItem)
{
$productId = $this->resolveProductId($productSku);
$websiteId = $stockItem->getWebsiteId() ?: null;
Expand All @@ -182,6 +195,8 @@ public function updateStockItemBySku($productSku, \Magento\CatalogInventory\Api\
}

/**
* Resolve the Product Id
*
* @param string $productSku
* @return int
* @throws \Magento\Framework\Exception\NoSuchEntityException
Expand Down
15 changes: 11 additions & 4 deletions app/code/Magento/CatalogInventory/Model/StockRegistryProvider.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
* Copyright 2024 Adobe
* All Rights Reserved.
*/
namespace Magento\CatalogInventory\Model;

Expand All @@ -15,10 +15,9 @@
use Magento\CatalogInventory\Api\StockCriteriaInterfaceFactory;
use Magento\CatalogInventory\Api\StockItemCriteriaInterfaceFactory;
use Magento\CatalogInventory\Api\StockStatusCriteriaInterfaceFactory;
use Magento\Store\Model\StoreManagerInterface;

/**
* Class StockRegistryProvider
* Class Catalog StockRegistryProvider
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class StockRegistryProvider implements StockRegistryProviderInterface
Expand Down Expand Up @@ -108,6 +107,8 @@ public function __construct(
}

/**
* Get Stock
*
* @param int|null $scopeId
* @return \Magento\CatalogInventory\Api\Data\StockInterface
*/
Expand All @@ -129,6 +130,8 @@ public function getStock($scopeId)
}

/**
* Get Stock Item
*
* @param int $productId
* @param int $scopeId
* @return \Magento\CatalogInventory\Api\Data\StockItemInterface
Expand All @@ -151,6 +154,8 @@ public function getStockItem($productId, $scopeId)
}

/**
* Get Stock Status
*
* @param int $productId
* @param int $scopeId
* @return \Magento\CatalogInventory\Api\Data\StockStatusInterface
Expand All @@ -174,6 +179,8 @@ public function getStockStatus($productId, $scopeId)
}

/**
* Get Stock Registry Storage
*
* @return StockRegistryStorage
*/
private function getStockRegistryStorage()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
* Copyright 2018 Adobe
* All Rights Reserved.
*/

namespace Magento\CatalogInventory\Setup\Patch\Data;

use Magento\Eav\Setup\EavSetup;
use Magento\Eav\Setup\EavSetupFactory;
use Magento\Framework\App\ResourceConnection;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Framework\Setup\Patch\DataPatchInterface;
use Magento\Framework\Setup\Patch\PatchVersionInterface;

/**
* Class CreateDefaultStock
* @package Magento\CatalogInventory\Setup\Patch
* Class CreateDefaultStock patch
*/
class CreateDefaultStock implements DataPatchInterface, PatchVersionInterface
{
Expand Down Expand Up @@ -43,7 +41,13 @@ public function __construct(
}

/**
* {@inheritdoc}
* Run code inside patch
* If code fails, patch must be reverted, in case when we are speaking about schema - then under revert
* means run PatchInterface::revert()
*
* If we speak about data, under revert means: $transaction->rollback()
*
* @return void
*/
public function apply()
{
Expand All @@ -66,23 +70,23 @@ public function apply()
}

/**
* {@inheritdoc}
* @inheritdoc
*/
public static function getDependencies()
{
return [];
}

/**
* {@inheritdoc}
* @inheritdoc
*/
public static function getVersion()
{
return '2.0.0';
}

/**
* {@inheritdoc}
* @inheritdoc
*/
public function getAliases()
{
Expand Down
Loading