Magento 2 how to get Multi source inventory names website wise?How to get Tier Price of product magento2?Why Getting categories and names on product view page Magento 2 fails?Magento 2.1 Create a filter in the product grid by new attributeMagento 2 Create dynamic array From different Model Collection to use in multi select in gridDowonloadable Product with MSI(Multi Source Inventory)Magento 2.3 How to get all the Multi Source Inventory (MSI) locations collection in custom module?Magento 2 : How to get collection of all sources "MSI (multi source inventory)?How can I set Source Priority for Source Selection Algorithm in Magento MSI (Multi Stock Inventory)?How to add product qty and product price store wise progrmatically in magento 2Magento 2 How can i get all out of stock product collection?
What happens if a creature that would fight isn't on the battlefield anymore?
What are the components of a legend (in the sense of a tale, not a figure legend)?
Create a list of all possible Boolean configurations of three constraints
Why not just directly invest in the holdings of an ETF?
Why was Thor doubtful about his worthiness to Mjolnir?
Why doesn't Rocket Lab use a solid stage?
Who was this character from the Tomb of Annihilation adventure before they became a monster?
Page contents aligning weirdly in LaTeX/Overleaf
Are there variations of the regular runtimes of the Big-O-Notation?
Was this a power play by Daenerys?
What does the expression "right on the tip of my tongue" mean?
How do I tell my supervisor that he is choosing poor replacements for me while I am on maternity leave?
Was this character’s old age look CGI or make-up?
What stroke width Instagram is using for its icons and how to get same results?
What is Plautus’s pun about frustum and frustrum?
Size of a folder with du
What food production methods would allow a metropolis like New York to become self sufficient
Can I use my laptop, which says 100-240V, in the USA?
Early arrival in Australia, early hotel check in not available
Plastic-on-plastic lubricant that wont leave a residue?
How does Howard Stark know this?
How to minimise the cost of guessing a number in a high/low guess game?
How can this pool heater gas line be disconnected?
On what legal basis did the UK remove the 'European Union' from its passport?
Magento 2 how to get Multi source inventory names website wise?
How to get Tier Price of product magento2?Why Getting categories and names on product view page Magento 2 fails?Magento 2.1 Create a filter in the product grid by new attributeMagento 2 Create dynamic array From different Model Collection to use in multi select in gridDowonloadable Product with MSI(Multi Source Inventory)Magento 2.3 How to get all the Multi Source Inventory (MSI) locations collection in custom module?Magento 2 : How to get collection of all sources "MSI (multi source inventory)?How can I set Source Priority for Source Selection Algorithm in Magento MSI (Multi Stock Inventory)?How to add product qty and product price store wise progrmatically in magento 2Magento 2 How can i get all out of stock product collection?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
How to get source names website wise from multisource inventory?
I have below code for getting all names from a collection of inventory sources:
use MagentoInventoryModelResourceModelSourceCollection as InventoryCollection;
public function __construct(
Context $context,
InventoryCollection $inventoryCollection
)
parent::__construct($context);
$this->_inventoryCollection = $inventoryCollection;
public function getInventorySources()
$sourceListArr = $this->_inventoryCollection->load();
$sourceList=[];
$sourceAllList=[];
$sourceList = array();
foreach ($sourceListArr as $sourceItemName)
$sourceList['sourceName'] = $sourceItemName->getName();
$sourceAllList[] = $sourceList;
return $sourceAllList;
It will return all the sources, Here I want to get website wise source names,
How can I achieve this functionality?
magento2 inventory multi-source-inventory msi
add a comment |
How to get source names website wise from multisource inventory?
I have below code for getting all names from a collection of inventory sources:
use MagentoInventoryModelResourceModelSourceCollection as InventoryCollection;
public function __construct(
Context $context,
InventoryCollection $inventoryCollection
)
parent::__construct($context);
$this->_inventoryCollection = $inventoryCollection;
public function getInventorySources()
$sourceListArr = $this->_inventoryCollection->load();
$sourceList=[];
$sourceAllList=[];
$sourceList = array();
foreach ($sourceListArr as $sourceItemName)
$sourceList['sourceName'] = $sourceItemName->getName();
$sourceAllList[] = $sourceList;
return $sourceAllList;
It will return all the sources, Here I want to get website wise source names,
How can I achieve this functionality?
magento2 inventory multi-source-inventory msi
add a comment |
How to get source names website wise from multisource inventory?
I have below code for getting all names from a collection of inventory sources:
use MagentoInventoryModelResourceModelSourceCollection as InventoryCollection;
public function __construct(
Context $context,
InventoryCollection $inventoryCollection
)
parent::__construct($context);
$this->_inventoryCollection = $inventoryCollection;
public function getInventorySources()
$sourceListArr = $this->_inventoryCollection->load();
$sourceList=[];
$sourceAllList=[];
$sourceList = array();
foreach ($sourceListArr as $sourceItemName)
$sourceList['sourceName'] = $sourceItemName->getName();
$sourceAllList[] = $sourceList;
return $sourceAllList;
It will return all the sources, Here I want to get website wise source names,
How can I achieve this functionality?
magento2 inventory multi-source-inventory msi
How to get source names website wise from multisource inventory?
I have below code for getting all names from a collection of inventory sources:
use MagentoInventoryModelResourceModelSourceCollection as InventoryCollection;
public function __construct(
Context $context,
InventoryCollection $inventoryCollection
)
parent::__construct($context);
$this->_inventoryCollection = $inventoryCollection;
public function getInventorySources()
$sourceListArr = $this->_inventoryCollection->load();
$sourceList=[];
$sourceAllList=[];
$sourceList = array();
foreach ($sourceListArr as $sourceItemName)
$sourceList['sourceName'] = $sourceItemName->getName();
$sourceAllList[] = $sourceList;
return $sourceAllList;
It will return all the sources, Here I want to get website wise source names,
How can I achieve this functionality?
magento2 inventory multi-source-inventory msi
magento2 inventory multi-source-inventory msi
edited May 8 at 9:53
Utsav Gupta
asked May 8 at 8:29
Utsav GuptaUtsav Gupta
441215
441215
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
I did below as a solution:
use MagentoInventoryModelResourceModelSourceCollection as InventoryCollection;
use MagentoFrameworkApiSortOrderBuilder;
use MagentoInventoryApiApiGetStockSourceLinksInterface;
use MagentoInventoryApiApiDataStockSourceLinkInterface;
use MagentoInventoryApiApiDataSourceInterface;
use MagentoFrameworkAppResourceConnection;
use MagentoFrameworkApiSearchCriteriaBuilder;
public function __construct(
Context $context,
InventoryCollection $inventoryCollection,
InventoryCollection $inventoryCollection,
SortOrderBuilder $sortOrderBuilder,
GetStockSourceLinksInterface $getStockSourceLinks,
ResourceConnection $resourceConnection,
SearchCriteriaBuilder $searchCriteriaBuilder,
)
parent::__construct($context);
$this->_inventoryCollection = $inventoryCollection;
$this->_inventoryCollection = $inventoryCollection;
$this->sortOrderBuilder = $sortOrderBuilder;
$this->getStockSourceLinks = $getStockSourceLinks;
$this->resourceConnection = $resourceConnection;
$this->_searchCriteriaBuilder = $searchCriteriaBuilder;
public function getInventorySources()
$websiteCode = $this->_storeManager->getStore()->getWebsite()->getCode();
$connection = $this->resourceConnection->getConnection();
$tableName = $this->resourceConnection->getTableName('inventory_stock_sales_channel');
$select = $connection->select()
->from($tableName)
->where('code = ?', $websiteCode);
$StockCollection = $connection->fetchAll($select);
$stockId = $StockCollection[0]['stock_id'];
$sortOrder = $this->sortOrderBuilder
->setField(StockSourceLinkInterface::PRIORITY)
->setAscendingDirection()
->create();
$searchCriteria = $this->_searchCriteriaBuilder
->addFilter(StockSourceLinkInterface::STOCK_ID, $stockId)
->addSortOrder($sortOrder)
->create();
$searchResult = $this->getStockSourceLinks->execute($searchCriteria);
if ($searchResult->getTotalCount() === 0)
return [];
$assignedSourcesData = [];
foreach ($searchResult->getItems() as $link)
$source = $this->_sourceRepository->get($link->getSourceCode());
$assignedSourcesData[] = [
'sourceName' => $source->getName(),
];
return $assignedSourcesData;
Thanks!
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "479"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f273792%2fmagento-2-how-to-get-multi-source-inventory-names-website-wise%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I did below as a solution:
use MagentoInventoryModelResourceModelSourceCollection as InventoryCollection;
use MagentoFrameworkApiSortOrderBuilder;
use MagentoInventoryApiApiGetStockSourceLinksInterface;
use MagentoInventoryApiApiDataStockSourceLinkInterface;
use MagentoInventoryApiApiDataSourceInterface;
use MagentoFrameworkAppResourceConnection;
use MagentoFrameworkApiSearchCriteriaBuilder;
public function __construct(
Context $context,
InventoryCollection $inventoryCollection,
InventoryCollection $inventoryCollection,
SortOrderBuilder $sortOrderBuilder,
GetStockSourceLinksInterface $getStockSourceLinks,
ResourceConnection $resourceConnection,
SearchCriteriaBuilder $searchCriteriaBuilder,
)
parent::__construct($context);
$this->_inventoryCollection = $inventoryCollection;
$this->_inventoryCollection = $inventoryCollection;
$this->sortOrderBuilder = $sortOrderBuilder;
$this->getStockSourceLinks = $getStockSourceLinks;
$this->resourceConnection = $resourceConnection;
$this->_searchCriteriaBuilder = $searchCriteriaBuilder;
public function getInventorySources()
$websiteCode = $this->_storeManager->getStore()->getWebsite()->getCode();
$connection = $this->resourceConnection->getConnection();
$tableName = $this->resourceConnection->getTableName('inventory_stock_sales_channel');
$select = $connection->select()
->from($tableName)
->where('code = ?', $websiteCode);
$StockCollection = $connection->fetchAll($select);
$stockId = $StockCollection[0]['stock_id'];
$sortOrder = $this->sortOrderBuilder
->setField(StockSourceLinkInterface::PRIORITY)
->setAscendingDirection()
->create();
$searchCriteria = $this->_searchCriteriaBuilder
->addFilter(StockSourceLinkInterface::STOCK_ID, $stockId)
->addSortOrder($sortOrder)
->create();
$searchResult = $this->getStockSourceLinks->execute($searchCriteria);
if ($searchResult->getTotalCount() === 0)
return [];
$assignedSourcesData = [];
foreach ($searchResult->getItems() as $link)
$source = $this->_sourceRepository->get($link->getSourceCode());
$assignedSourcesData[] = [
'sourceName' => $source->getName(),
];
return $assignedSourcesData;
Thanks!
add a comment |
I did below as a solution:
use MagentoInventoryModelResourceModelSourceCollection as InventoryCollection;
use MagentoFrameworkApiSortOrderBuilder;
use MagentoInventoryApiApiGetStockSourceLinksInterface;
use MagentoInventoryApiApiDataStockSourceLinkInterface;
use MagentoInventoryApiApiDataSourceInterface;
use MagentoFrameworkAppResourceConnection;
use MagentoFrameworkApiSearchCriteriaBuilder;
public function __construct(
Context $context,
InventoryCollection $inventoryCollection,
InventoryCollection $inventoryCollection,
SortOrderBuilder $sortOrderBuilder,
GetStockSourceLinksInterface $getStockSourceLinks,
ResourceConnection $resourceConnection,
SearchCriteriaBuilder $searchCriteriaBuilder,
)
parent::__construct($context);
$this->_inventoryCollection = $inventoryCollection;
$this->_inventoryCollection = $inventoryCollection;
$this->sortOrderBuilder = $sortOrderBuilder;
$this->getStockSourceLinks = $getStockSourceLinks;
$this->resourceConnection = $resourceConnection;
$this->_searchCriteriaBuilder = $searchCriteriaBuilder;
public function getInventorySources()
$websiteCode = $this->_storeManager->getStore()->getWebsite()->getCode();
$connection = $this->resourceConnection->getConnection();
$tableName = $this->resourceConnection->getTableName('inventory_stock_sales_channel');
$select = $connection->select()
->from($tableName)
->where('code = ?', $websiteCode);
$StockCollection = $connection->fetchAll($select);
$stockId = $StockCollection[0]['stock_id'];
$sortOrder = $this->sortOrderBuilder
->setField(StockSourceLinkInterface::PRIORITY)
->setAscendingDirection()
->create();
$searchCriteria = $this->_searchCriteriaBuilder
->addFilter(StockSourceLinkInterface::STOCK_ID, $stockId)
->addSortOrder($sortOrder)
->create();
$searchResult = $this->getStockSourceLinks->execute($searchCriteria);
if ($searchResult->getTotalCount() === 0)
return [];
$assignedSourcesData = [];
foreach ($searchResult->getItems() as $link)
$source = $this->_sourceRepository->get($link->getSourceCode());
$assignedSourcesData[] = [
'sourceName' => $source->getName(),
];
return $assignedSourcesData;
Thanks!
add a comment |
I did below as a solution:
use MagentoInventoryModelResourceModelSourceCollection as InventoryCollection;
use MagentoFrameworkApiSortOrderBuilder;
use MagentoInventoryApiApiGetStockSourceLinksInterface;
use MagentoInventoryApiApiDataStockSourceLinkInterface;
use MagentoInventoryApiApiDataSourceInterface;
use MagentoFrameworkAppResourceConnection;
use MagentoFrameworkApiSearchCriteriaBuilder;
public function __construct(
Context $context,
InventoryCollection $inventoryCollection,
InventoryCollection $inventoryCollection,
SortOrderBuilder $sortOrderBuilder,
GetStockSourceLinksInterface $getStockSourceLinks,
ResourceConnection $resourceConnection,
SearchCriteriaBuilder $searchCriteriaBuilder,
)
parent::__construct($context);
$this->_inventoryCollection = $inventoryCollection;
$this->_inventoryCollection = $inventoryCollection;
$this->sortOrderBuilder = $sortOrderBuilder;
$this->getStockSourceLinks = $getStockSourceLinks;
$this->resourceConnection = $resourceConnection;
$this->_searchCriteriaBuilder = $searchCriteriaBuilder;
public function getInventorySources()
$websiteCode = $this->_storeManager->getStore()->getWebsite()->getCode();
$connection = $this->resourceConnection->getConnection();
$tableName = $this->resourceConnection->getTableName('inventory_stock_sales_channel');
$select = $connection->select()
->from($tableName)
->where('code = ?', $websiteCode);
$StockCollection = $connection->fetchAll($select);
$stockId = $StockCollection[0]['stock_id'];
$sortOrder = $this->sortOrderBuilder
->setField(StockSourceLinkInterface::PRIORITY)
->setAscendingDirection()
->create();
$searchCriteria = $this->_searchCriteriaBuilder
->addFilter(StockSourceLinkInterface::STOCK_ID, $stockId)
->addSortOrder($sortOrder)
->create();
$searchResult = $this->getStockSourceLinks->execute($searchCriteria);
if ($searchResult->getTotalCount() === 0)
return [];
$assignedSourcesData = [];
foreach ($searchResult->getItems() as $link)
$source = $this->_sourceRepository->get($link->getSourceCode());
$assignedSourcesData[] = [
'sourceName' => $source->getName(),
];
return $assignedSourcesData;
Thanks!
I did below as a solution:
use MagentoInventoryModelResourceModelSourceCollection as InventoryCollection;
use MagentoFrameworkApiSortOrderBuilder;
use MagentoInventoryApiApiGetStockSourceLinksInterface;
use MagentoInventoryApiApiDataStockSourceLinkInterface;
use MagentoInventoryApiApiDataSourceInterface;
use MagentoFrameworkAppResourceConnection;
use MagentoFrameworkApiSearchCriteriaBuilder;
public function __construct(
Context $context,
InventoryCollection $inventoryCollection,
InventoryCollection $inventoryCollection,
SortOrderBuilder $sortOrderBuilder,
GetStockSourceLinksInterface $getStockSourceLinks,
ResourceConnection $resourceConnection,
SearchCriteriaBuilder $searchCriteriaBuilder,
)
parent::__construct($context);
$this->_inventoryCollection = $inventoryCollection;
$this->_inventoryCollection = $inventoryCollection;
$this->sortOrderBuilder = $sortOrderBuilder;
$this->getStockSourceLinks = $getStockSourceLinks;
$this->resourceConnection = $resourceConnection;
$this->_searchCriteriaBuilder = $searchCriteriaBuilder;
public function getInventorySources()
$websiteCode = $this->_storeManager->getStore()->getWebsite()->getCode();
$connection = $this->resourceConnection->getConnection();
$tableName = $this->resourceConnection->getTableName('inventory_stock_sales_channel');
$select = $connection->select()
->from($tableName)
->where('code = ?', $websiteCode);
$StockCollection = $connection->fetchAll($select);
$stockId = $StockCollection[0]['stock_id'];
$sortOrder = $this->sortOrderBuilder
->setField(StockSourceLinkInterface::PRIORITY)
->setAscendingDirection()
->create();
$searchCriteria = $this->_searchCriteriaBuilder
->addFilter(StockSourceLinkInterface::STOCK_ID, $stockId)
->addSortOrder($sortOrder)
->create();
$searchResult = $this->getStockSourceLinks->execute($searchCriteria);
if ($searchResult->getTotalCount() === 0)
return [];
$assignedSourcesData = [];
foreach ($searchResult->getItems() as $link)
$source = $this->_sourceRepository->get($link->getSourceCode());
$assignedSourcesData[] = [
'sourceName' => $source->getName(),
];
return $assignedSourcesData;
Thanks!
answered 2 days ago
Utsav GuptaUtsav Gupta
441215
441215
add a comment |
add a comment |
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f273792%2fmagento-2-how-to-get-multi-source-inventory-names-website-wise%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown