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;








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?










share|improve this question






























    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?










    share|improve this question


























      0












      0








      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?










      share|improve this question
















      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






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited May 8 at 9:53







      Utsav Gupta

















      asked May 8 at 8:29









      Utsav GuptaUtsav Gupta

      441215




      441215




















          1 Answer
          1






          active

          oldest

          votes


















          0














          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!






          share|improve this answer























            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
            );



            );













            draft saved

            draft discarded


















            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









            0














            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!






            share|improve this answer



























              0














              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!






              share|improve this answer

























                0












                0








                0







                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!






                share|improve this answer













                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!







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered 2 days ago









                Utsav GuptaUtsav Gupta

                441215




                441215



























                    draft saved

                    draft discarded
















































                    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.




                    draft saved


                    draft discarded














                    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





















































                    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







                    Popular posts from this blog

                    Category:9 (number) SubcategoriesMedia in category "9 (number)"Navigation menuUpload mediaGND ID: 4485639-8Library of Congress authority ID: sh85091979ReasonatorScholiaStatistics

                    Circuit construction for execution of conditional statements using least significant bitHow are two different registers being used as “control”?How exactly is the stated composite state of the two registers being produced using the $R_zz$ controlled rotations?Efficiently performing controlled rotations in HHLWould this quantum algorithm implementation work?How to prepare a superposed states of odd integers from $1$ to $sqrtN$?Why is this implementation of the order finding algorithm not working?Circuit construction for Hamiltonian simulationHow can I invert the least significant bit of a certain term of a superposed state?Implementing an oracleImplementing a controlled sum operation

                    Magento 2 “No Payment Methods” in Admin New OrderHow to integrate Paypal Express Checkout with the Magento APIMagento 1.5 - Sales > Order > edit order and shipping methods disappearAuto Invoice Check/Money Order Payment methodAdd more simple payment methods?Shipping methods not showingWhat should I do to change payment methods if changing the configuration has no effects?1.9 - No Payment Methods showing upMy Payment Methods not Showing for downloadable/virtual product when checkout?Magento2 API to access internal payment methodHow to call an existing payment methods in the registration form?