{"id":18564901,"url":"https://github.com/bdcrops/module-minventory","last_synced_at":"2025-05-15T18:34:59.970Z","repository":{"id":62492496,"uuid":"209835514","full_name":"bdcrops/module-minventory","owner":"bdcrops","description":null,"archived":false,"fork":false,"pushed_at":"2019-09-20T18:13:17.000Z","size":414,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-12-26T12:09:50.774Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bdcrops.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-09-20T16:31:01.000Z","updated_at":"2019-09-20T18:13:19.000Z","dependencies_parsed_at":"2022-11-02T11:30:40.854Z","dependency_job_id":null,"html_url":"https://github.com/bdcrops/module-minventory","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bdcrops%2Fmodule-minventory","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bdcrops%2Fmodule-minventory/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bdcrops%2Fmodule-minventory/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bdcrops%2Fmodule-minventory/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bdcrops","download_url":"https://codeload.github.com/bdcrops/module-minventory/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239293948,"owners_count":19615043,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-06T22:16:46.180Z","updated_at":"2025-02-17T13:14:38.931Z","avatar_url":"https://github.com/bdcrops.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n\n# BDC_Minventory\n\nThis module is used as a resupply for stock BDCrops Magento 2 extensions.\nMagento 2 Stock / Inventory Management, demonstrating UI grid.\n\n## Goal\n- Quick Stock / Inventory update from admin\n- Easily bump up product stock in certain increments without ever getting access to other areas of the Magento admin.\n- Better understanding of the adminhtml developing for the adminhtml area\n- Using the listing  \u0026 form component\n\n\n## How to install \u0026 upgrade BDC_Minventory\n\n\n### 1.1 Copy and paste\n\nIf you don't want to install via composer, you can use this way.\n\n- Download [the latest version here](https://github.com/bdcrops/module-minventory/archive/master.zip)\n- Extract `master.zip` file to `app/code/BDC/Core` ; You should create a folder path `app/code/BDC/Core` if not exist.\n- Go to Magento root folder and run upgrade command line to install `BDC_Minventory`:\n\n\n\n\n\n### 1.2 Install via composer\n\nWe recommend you to install BDC_Minventory module via composer. It is easy to install, update and maintaince.Run the following command in Magento 2 root folder.\n\n```\ncomposer config repositories.module-minventory git\nhttps://github.com/bdcrops/module-minventory.git\n\ncomposer require bdc/module-minventory:~1.0.0\nphp bin/magento setup:upgrade\nphp bin/magento setup:static-content:deploy\n```\n\n#### 1.2 Upgrade    \n\n```\ncomposer update bdcrops/module-minventory\nphp bin/magento setup:upgrade\nphp bin/magento setup:static-content:deploy\n```\n\nRun compile if your store in Product mode:\n\n```\nphp bin/magento setup:di:compile\n\n```\n## Tutorial Module Step By Step (BDCrops)\n\n\n- create app/code/BDC/Minventory/registration.php\n```    \n\u003c?php\n\\Magento\\Framework\\Component\\ComponentRegistrar::register(\n    \\Magento\\Framework\\Component\\ComponentRegistrar::MODULE,\n    'BDC_Minventory',\n    __DIR__\n);\n```\n- create a app/code/BDC/Minventory/etc/module.xml\n```   \n\u003c?xml version=\"1.0\"?\u003e\n\u003cconfig xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"urn:magento:framework:Module/etc/module.xsd\"\u003e\n    \u003cmodule name=\"BDC_Minventory\" setup_version=\"1.0.0\"/\u003e\n\u003c/config\u003e\n ```\n - create a app/code/BDC/Minventory/etc/adminhtml/routes.xml\n```  \n\u003c?xml version=\"1.0\"?\u003e\n\u003cconfig xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"urn:magento:framework:App/etc/routes.xsd\"\u003e\n    \u003crouter id=\"admin\"\u003e\n        \u003croute id=\"minventory\" frontName=\"minventory\"\u003e\n            \u003cmodule name=\"BDC_Minventory\"/\u003e\n        \u003c/route\u003e\n    \u003c/router\u003e\n\u003c/config\u003e  \n```\n- create a app/code/BDC/Minventory/Controller/Adminhtml/Product.php\n```\n\u003c?php\nnamespace BDC\\Minventory\\Controller\\Adminhtml;\nabstract class Product extends \\Magento\\Backend\\App\\Action {\n    const ADMIN_RESOURCE = 'BDC_Minventory::minventory';\n}\n\n```\n- create a app/code/BDC/Minventory/Controller/Adminhtml/Product/Index.php\n```    \n\u003c?php\nnamespace BDC\\Minventory\\Controller\\Adminhtml\\Product;\n\nuse \\Magento\\Framework\\Controller\\ResultFactory;\n\nclass Index extends \\BDC\\Minventory\\Controller\\Adminhtml\\Product{\n    public function execute(){\n        $resultPage = $this-\u003eresultFactory-\u003ecreate(ResultFactory::TYPE_PAGE);\n        $resultPage-\u003egetConfig()-\u003egetTitle()-\u003eprepend((__('Micro Inventory')));\n        return $resultPage;\n    }\n}\n```\n- create a app/code/BDC/Minventory/Controller/Adminhtml/Product/MassResupply.php\n```    \n\u003c?php\n\nnamespace BDC\\Minventory\\Controller\\Adminhtml\\Product;\nuse \\Magento\\Framework\\Controller\\ResultFactory;\n\nclass MassResupply extends \\BDC\\Minventory\\Controller\\Adminhtml\\Product {\n    protected $filter;\n    protected $collectionFactory;\n    protected $resupply;\n\n    public function __construct(\n        \\Magento\\Backend\\App\\Action\\Context $context,\n        \\Magento\\Ui\\Component\\MassAction\\Filter $filter,\n        \\Magento\\Catalog\\Model\\ResourceModel\\Product\\CollectionFactory $collectionFactory,\n        \\BDC\\Minventory\\Model\\Resupply $resupply\n    ){\n        parent::__construct($context);\n        $this-\u003efilter = $filter;\n        $this-\u003ecollectionFactory = $collectionFactory;\n        $this-\u003eresupply = $resupply;\n    }\n\n    public function execute(){\n        $redirectResult = $this-\u003eresultFactory-\u003ecreate(ResultFactory::TYPE_REDIRECT);\n        $qty = $this-\u003egetRequest()-\u003egetParam('qty');\n        $collection = $this-\u003efilter-\u003egetCollection($this-\u003ecollectionFactory-\u003ecreate());\n        $productResupplied = 0;\n        foreach ($collection-\u003egetItems() as $product) {\n            $this-\u003eresupply-\u003eresupply($product-\u003egetId(), $qty);\n            $productResupplied++;\n        }\n\n        $this-\u003emessageManager-\u003eaddSuccessMessage(__('A total of %1 record(s) have been resupplied.', $productResupplied));\n        return $redirectResult-\u003esetPath('minventory/product/index');\n    }\n}\n\n```\n- create a app/code/BDC/Minventory/Controller/Adminhtml/Product/Resupply.php\n```    \n\u003c?php\n\nnamespace BDC\\Minventory\\Controller\\Adminhtml\\Product;\n\nuse \\Magento\\Framework\\Controller\\ResultFactory;\n\nclass Resupply extends \\BDC\\Minventory\\Controller\\Adminhtml\\Product{\n    protected $stockRegistry;\n    protected $productRepository;\n    protected $resupply;\n\n    public function __construct(\n        \\Magento\\Backend\\App\\Action\\Context $context,\n        \\Magento\\Catalog\\Api\\ProductRepositoryInterface $productRepository,\n        \\Magento\\CatalogInventory\\Api\\StockRegistryInterface $stockRegistry,\n        \\BDC\\Minventory\\Model\\Resupply $resupply\n    ) {\n        parent::__construct($context);\n        $this-\u003eproductRepository = $productRepository;\n        $this-\u003estockRegistry = $stockRegistry;\n        $this-\u003eresupply = $resupply;\n    }\n\n    public function execute() {\n        if ($this-\u003egetRequest()-\u003eisPost()) {\n            $this-\u003eresupply-\u003eresupply(\n                $this-\u003egetRequest()-\u003egetParam('id'),\n                $_POST['minventory_product']['qty']\n            );\n            $this-\u003emessageManager-\u003eaddSuccessMessage(__('Successfully resupplied'));\n            $redirectResult = $this-\u003eresultFactory-\u003ecreate(ResultFactory::TYPE_REDIRECT);\n            return $redirectResult-\u003esetPath('minventory/product/index');\n        } else {\n            $resultPage = $this-\u003eresultFactory-\u003ecreate(ResultFactory::TYPE_PAGE);\n            $resultPage-\u003egetConfig()-\u003egetTitle()-\u003eprepend((__('Stock Resupply')));\n            return $resultPage;\n        }\n    }\n}\n\n```\n- create a app/code/BDC/Minventory/Model/Resupply.php\n```    \n\u003c?php\n\nnamespace BDC\\Minventory\\Model;\n\nclass Resupply{\n    protected $productRepository;\n    protected $collectionFactory;\n    protected $stockRegistry;\n\n    public function __construct(\n        \\Magento\\Catalog\\Api\\ProductRepositoryInterface $productRepository,\n        \\Magento\\Catalog\\Model\\ResourceModel\\Product\\CollectionFactory $collectionFactory,\n        \\Magento\\CatalogInventory\\Api\\StockRegistryInterface $stockRegistry\n    ) {\n        $this-\u003eproductRepository = $productRepository;\n        $this-\u003ecollectionFactory = $collectionFactory;\n        $this-\u003estockRegistry = $stockRegistry;\n    }\n\n    public function resupply($productId, $qty) {\n        $product = $this-\u003eproductRepository-\u003egetById($productId);\n        $stockItem = $this-\u003estockRegistry-\u003egetStockItemBySku($product-\u003egetSku());\n        $stockItem-\u003esetQty($stockItem-\u003egetQty() + $qty);\n        $stockItem-\u003esetIsInStock((bool)$stockItem-\u003egetQty());\n        $this-\u003estockRegistry-\u003eupdateStockItemBySku($product-\u003egetSku(), $stockItem);\n    }\n}\n\n```\n- create a app/code/BDC/Minventory/etc/adminhtml/menu.xml\n```    \n\u003c?xml version=\"1.0\"?\u003e\n\n\u003cconfig xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n        xsi:noNamespaceSchemaLocation=\"urn:magento:module:Magento_Backend:etc/menu.xsd\"\u003e\n    \u003cmenu\u003e\n        \u003cadd id=\"BDC_Minventory::minventory\" title=\"Micro Inventory\" translate=\"title\"\n             module=\"BDC_Minventory\" sortOrder=\"100\" parent=\"Magento_Catalog::inventory\"\n             action=\"minventory/product/index\" resource=\"BDC_Minventory::minventory\"/\u003e\n    \u003c/menu\u003e\n\u003c/config\u003e\n\n```\n![](docs/menuDash.png)\n\n\n- create a app/code/BDC/Minventory/etc/acl.xml\n```    \n\u003c?xml version=\"1.0\"?\u003e\n\n\u003cconfig xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n        xsi:noNamespaceSchemaLocation=\"urn:magento:framework:Acl/etc/acl.xsd\"\u003e\n    \u003cacl\u003e\n        \u003cresources\u003e\n            \u003cresource id=\"Magento_Backend::admin\"\u003e\n                \u003cresource id=\"Magento_Catalog::catalog\"\u003e\n                    \u003cresource id=\"Magento_Catalog::catalog_inventory\"\u003e\n                        \u003cresource id=\"BDC_Minventory::minventory\" title=\"Micro Inventory\" translate=\"title\"\n                                  sortOrder=\"30\"/\u003e\n                    \u003c/resource\u003e\n                \u003c/resource\u003e\n            \u003c/resource\u003e\n        \u003c/resources\u003e\n    \u003c/acl\u003e\n\u003c/config\u003e\n\n```\n![](docs/aclMenu.png)\n\n- create a app/code/BDC/Minventory/view/adminhtml/layout/minventory_product_index.xml\n```    \n\u003c?xml version=\"1.0\"?\u003e\n\u003cpage xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd\"\u003e\n    \u003cupdate handle=\"styles\"/\u003e\n    \u003cbody\u003e\n        \u003creferenceContainer name=\"content\"\u003e\n            \u003cuiComponent name=\"minventory_listing\"/\u003e\n        \u003c/referenceContainer\u003e\n    \u003c/body\u003e\n\u003c/page\u003e\n\n```\n- create a app/code/BDC/Minventory/view/adminhtml/layout/minventory_product_resupply.xml\n```\n\u003c?xml version=\"1.0\"?\u003e\n\u003cpage xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n      xsi:noNamespaceSchemaLocation=\"../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd\"\u003e\n    \u003cupdate handle=\"styles\"/\u003e\n    \u003cbody\u003e\n        \u003creferenceContainer name=\"content\"\u003e\n            \u003cuiComponent name=\"minventory_resupply_form\"/\u003e\n        \u003c/referenceContainer\u003e\n    \u003c/body\u003e\n\u003c/page\u003e\n\n```\n- create a app/code/BDC/Minventory/view/adminhtml/ui_component/minventory_listing.xml\n```    \n\u003c?xml version=\"1.0\" encoding=\"UTF-8\"?\u003e\n\n\u003clisting xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"urn:magento:module:Magento_Ui:etc/ui_configuration.xsd\"\u003e\n    \u003cargument name=\"data\" xsi:type=\"array\"\u003e\n        \u003citem name=\"js_config\" xsi:type=\"array\"\u003e\n            \u003citem name=\"provider\" xsi:type=\"string\"\u003eminventory_listing.minventory_listing_data_source\u003c/item\u003e\n        \u003c/item\u003e\n    \u003c/argument\u003e\n    \u003csettings\u003e\n        \u003cspinner\u003eminventory_columns\u003c/spinner\u003e\n        \u003cdeps\u003e\n            \u003cdep\u003eminventory_listing.minventory_listing_data_source\u003c/dep\u003e\n        \u003c/deps\u003e\n    \u003c/settings\u003e\n    \u003cdataSource name=\"minventory_listing_data_source\" component=\"Magento_Ui/js/grid/provider\"\u003e\n        \u003csettings\u003e\n            \u003cstorageConfig\u003e\n                \u003cparam name=\"indexField\" xsi:type=\"string\"\u003eentity_id\u003c/param\u003e\n            \u003c/storageConfig\u003e\n            \u003cupdateUrl path=\"mui/index/render\"/\u003e\n        \u003c/settings\u003e\n        \u003cdataProvider class=\"BDC\\Minventory\\Ui\\DataProvider\\Product\\ProductDataProvider\" name=\"minventory_listing_data_source\"\u003e\n            \u003csettings\u003e\n                \u003crequestFieldName\u003eid\u003c/requestFieldName\u003e\n                \u003cprimaryFieldName\u003eentity_id\u003c/primaryFieldName\u003e\n            \u003c/settings\u003e\n        \u003c/dataProvider\u003e\n    \u003c/dataSource\u003e\n    \u003clistingToolbar name=\"listing_top\"\u003e\n        \u003cbookmark name=\"bookmarks\"/\u003e\n        \u003ccolumnsControls name=\"columns_controls\"/\u003e\n        \u003cfilters name=\"listing_filters\" /\u003e\n        \u003cfilters name=\"listing_filters\"\u003e\n            \u003cfilterSelect name=\"store_id\" provider=\"${ $.parentName }\"\u003e\n                \u003csettings\u003e\n                    \u003coptions class=\"Magento\\Store\\Ui\\Component\\Listing\\Column\\Store\\Options\"/\u003e\n                    \u003ccaption translate=\"true\"\u003eAll Store Views\u003c/caption\u003e\n                    \u003clabel translate=\"true\"\u003eStore View\u003c/label\u003e\n                    \u003cdataScope\u003estore_id\u003c/dataScope\u003e\n                \u003c/settings\u003e\n            \u003c/filterSelect\u003e\n        \u003c/filters\u003e\n        \u003cmassaction name=\"listing_massaction\" component=\"Magento_Ui/js/grid/tree-massactions\"\u003e\n            \u003caction name=\"resupply\"\u003e\n                \u003csettings\u003e\n                    \u003ctype\u003eresupply\u003c/type\u003e\n                    \u003clabel translate=\"true\"\u003eResupply\u003c/label\u003e\n                    \u003cactions\u003e\n                        \u003caction name=\"0\"\u003e\n                            \u003ctype\u003eresupply_10\u003c/type\u003e\n                            \u003clabel translate=\"true\"\u003eResupply +10\u003c/label\u003e\n                            \u003curl path=\"minventory/product/massResupply\"\u003e\n                                \u003cparam name=\"qty\"\u003e10\u003c/param\u003e\n                            \u003c/url\u003e\n                        \u003c/action\u003e\n                        \u003caction name=\"1\"\u003e\n                            \u003ctype\u003eresupply_50\u003c/type\u003e\n                            \u003clabel translate=\"true\"\u003eResupply +50\u003c/label\u003e\n                            \u003curl path=\"minventory/product/massResupply\"\u003e\n                                \u003cparam name=\"qty\"\u003e50\u003c/param\u003e\n                            \u003c/url\u003e\n                        \u003c/action\u003e\n                    \u003c/actions\u003e\n                \u003c/settings\u003e\n            \u003c/action\u003e\n        \u003c/massaction\u003e\n        \u003cpaging name=\"listing_paging\"/\u003e\n    \u003c/listingToolbar\u003e\n    \u003ccolumns name=\"minventory_columns\" class=\"Magento\\Catalog\\Ui\\Component\\Listing\\Columns\"\u003e\n        \u003csettings\u003e\n            \u003cchildDefaults\u003e\n                \u003cparam name=\"fieldAction\" xsi:type=\"array\"\u003e\n                    \u003citem name=\"provider\" xsi:type=\"string\"\u003eminventory_listing.minventory_listing.minventory_columns.actions\u003c/item\u003e\n                    \u003citem name=\"target\" xsi:type=\"string\"\u003eapplyAction\u003c/item\u003e\n                    \u003citem name=\"params\" xsi:type=\"array\"\u003e\n                        \u003citem name=\"0\" xsi:type=\"string\"\u003eresupply\u003c/item\u003e\n                        \u003citem name=\"1\" xsi:type=\"string\"\u003e${ $.$data.rowIndex }\u003c/item\u003e\n                    \u003c/item\u003e\n                \u003c/param\u003e\n            \u003c/childDefaults\u003e\n        \u003c/settings\u003e\n        \u003cselectionsColumn name=\"ids\" sortOrder=\"0\"\u003e\n            \u003csettings\u003e\n                \u003cindexField\u003eentity_id\u003c/indexField\u003e\n            \u003c/settings\u003e\n        \u003c/selectionsColumn\u003e\n        \u003ccolumn name=\"entity_id\" sortOrder=\"10\"\u003e\n            \u003csettings\u003e\n                \u003cfilter\u003etextRange\u003c/filter\u003e\n                \u003clabel translate=\"true\"\u003eID\u003c/label\u003e\n                \u003csorting\u003easc\u003c/sorting\u003e\n            \u003c/settings\u003e\n        \u003c/column\u003e\n        \u003ccolumn name=\"sku\" sortOrder=\"20\"\u003e\n            \u003csettings\u003e\n                \u003cfilter\u003etext\u003c/filter\u003e\n                \u003clabel translate=\"true\"\u003eSKU\u003c/label\u003e\n            \u003c/settings\u003e\n        \u003c/column\u003e\n        \u003ccolumn name=\"sku\" sortOrder=\"20\"\u003e\n            \u003csettings\u003e\n                \u003cfilter\u003etext\u003c/filter\u003e\n                \u003clabel translate=\"true\"\u003eSKU\u003c/label\u003e\n            \u003c/settings\u003e\n        \u003c/column\u003e\n        \u003ccolumn name=\"status\" component=\"Magento_Ui/js/grid/columns/select\" sortOrder=\"30\"\u003e\n            \u003csettings\u003e\n                \u003caddField\u003etrue\u003c/addField\u003e\n                \u003coptions class=\"Magento\\Catalog\\Model\\Product\\Attribute\\Source\\Status\"/\u003e\n                \u003cfilter\u003eselect\u003c/filter\u003e\n                \u003cdataType\u003eselect\u003c/dataType\u003e\n                \u003clabel translate=\"true\"\u003eStatus\u003c/label\u003e\n            \u003c/settings\u003e\n        \u003c/column\u003e\n        \u003ccolumn name=\"qty\" sortOrder=\"40\"\u003e\n            \u003csettings\u003e\n                \u003caddField\u003etrue\u003c/addField\u003e\n                \u003cfilter\u003etextRange\u003c/filter\u003e\n                \u003clabel translate=\"true\"\u003eQuantity\u003c/label\u003e\n            \u003c/settings\u003e\n        \u003c/column\u003e\n        \u003cactionsColumn name=\"resupply\" class=\"BDC\\Minventory\\Ui\\Component\\Listing\\Columns\\Resupply\" sortOrder=\"50\"\u003e\n            \u003csettings\u003e\n                \u003cindexField\u003eentity_id\u003c/indexField\u003e\n            \u003c/settings\u003e\n        \u003c/actionsColumn\u003e\n    \u003c/columns\u003e\n\u003c/listing\u003e\n\n```\n![](docs/UiComponent.png)\n\n- create a app/code/BDC/Minventory/view/adminhtml/ui_component/minventory_resupply_form.xml\n\n```    \n\u003c?xml version=\"1.0\" ?\u003e\n\u003cform xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"urn:magento:module:Magento_Ui:etc/ui_configuration.xsd\"\u003e\n    \u003cargument name=\"data\" xsi:type=\"array\"\u003e\n        \u003citem name=\"js_config\" xsi:type=\"array\"\u003e\n            \u003citem name=\"provider\" xsi:type=\"string\"\u003eminventory_resupply_form.minventory_resupply_form_data_source\u003c/item\u003e\n            \u003citem name=\"deps\" xsi:type=\"string\"\u003eminventory_resupply_form.minventory_resupply_form_data_source\u003c/item\u003e\n        \u003c/item\u003e\n        \u003citem name=\"layout\" xsi:type=\"array\"\u003e\n            \u003citem name=\"type\" xsi:type=\"string\"\u003etabs\u003c/item\u003e\n        \u003c/item\u003e\n    \u003c/argument\u003e\n    \u003csettings\u003e\n        \u003cbuttons\u003e\n            \u003cbutton name=\"save\" class=\"BDC\\Minventory\\Block\\Adminhtml\\Product\\Edit\\Button\\Save\"/\u003e\n            \u003cbutton name=\"back\" class=\"BDC\\Minventory\\Block\\Adminhtml\\Product\\Edit\\Button\\Back\"/\u003e\n        \u003c/buttons\u003e\n    \u003c/settings\u003e\n    \u003cdataSource name=\"minventory_resupply_form_data_source\"\u003e\n        \u003cargument name=\"data\" xsi:type=\"array\"\u003e\n            \u003citem name=\"js_config\" xsi:type=\"array\"\u003e\n                \u003citem name=\"component\" xsi:type=\"string\"\u003eMagento_Ui/js/form/provider\u003c/item\u003e\n            \u003c/item\u003e\n        \u003c/argument\u003e\n        \u003cdataProvider class=\"BDC\\Minventory\\Ui\\DataProvider\\Product\\Form\\ProductDataProvider\" name=\"minventory_resupply_form_data_source\"\u003e\n            \u003csettings\u003e\n                \u003crequestFieldName\u003eid\u003c/requestFieldName\u003e\n                \u003cprimaryFieldName\u003eentity_id\u003c/primaryFieldName\u003e\n            \u003c/settings\u003e\n        \u003c/dataProvider\u003e\n    \u003c/dataSource\u003e\n    \u003cfieldset name=\"minventory_product\"\u003e\n        \u003cargument name=\"data\" xsi:type=\"array\"\u003e\n            \u003citem name=\"config\" xsi:type=\"array\"\u003e\n                \u003citem name=\"label\" xsi:type=\"string\" translate=\"true\"\u003eGeneral\u003c/item\u003e\n            \u003c/item\u003e\n        \u003c/argument\u003e\n        \u003cfield name=\"stock\"\u003e\n            \u003cargument name=\"data\" xsi:type=\"array\"\u003e\n                \u003citem name=\"config\" xsi:type=\"array\"\u003e\n                    \u003citem name=\"label\" xsi:type=\"string\"\u003eStock\u003c/item\u003e\n                    \u003citem name=\"visible\" xsi:type=\"boolean\"\u003etrue\u003c/item\u003e\n                    \u003citem name=\"dataType\" xsi:type=\"string\"\u003etext\u003c/item\u003e\n                    \u003citem name=\"formElement\" xsi:type=\"string\"\u003einput\u003c/item\u003e\n                    \u003citem name=\"disabled\" xsi:type=\"string\"\u003etrue\u003c/item\u003e\n                \u003c/item\u003e\n            \u003c/argument\u003e\n        \u003c/field\u003e\n        \u003cfield name=\"qty\"\u003e\n            \u003cargument name=\"data\" xsi:type=\"array\"\u003e\n                \u003citem name=\"config\" xsi:type=\"array\"\u003e\n                    \u003citem name=\"label\" xsi:type=\"string\"\u003e+Qty\u003c/item\u003e\n                    \u003citem name=\"visible\" xsi:type=\"boolean\"\u003etrue\u003c/item\u003e\n                    \u003citem name=\"dataType\" xsi:type=\"string\"\u003etext\u003c/item\u003e\n                    \u003citem name=\"formElement\" xsi:type=\"string\"\u003einput\u003c/item\u003e\n                    \u003citem name=\"focused\" xsi:type=\"string\"\u003etrue\u003c/item\u003e\n                    \u003citem name=\"validation\" xsi:type=\"array\"\u003e\n                        \u003citem name=\"required-entry\" xsi:type=\"boolean\"\u003etrue\u003c/item\u003e\n                        \u003citem name=\"validate-zero-or-greater\" xsi:type=\"boolean\"\u003etrue\u003c/item\u003e\n                    \u003c/item\u003e\n                \u003c/item\u003e\n            \u003c/argument\u003e\n        \u003c/field\u003e\n    \u003c/fieldset\u003e\n\u003c/form\u003e\n\n```\n\n![](docs/resupplyStock.png)\n\n- create a app/code/BDC/Minventory/Block/Adminhtml/Product/Edit/Button/Back.php\n```    \n\u003c?php\n\nnamespace BDC\\Minventory\\Block\\Adminhtml\\Product\\Edit\\Button;\n\nclass Back extends \\Magento\\Backend\\Block\\Template implements \\Magento\\Framework\\View\\Element\\UiComponent\\Control\\ButtonProviderInterface\n{\n    public function getButtonData() {\n        return [\n            'label' =\u003e __('Back'),\n            'on_click' =\u003e sprintf(\"location.href = '%s';\", $this-\u003egetBackUrl()),\n            'class' =\u003e 'back',\n            'sort_order' =\u003e 10\n        ];\n    }\n\n    public function getBackUrl() {\n        return $this-\u003egetUrl('*/*/');\n    }\n}\n\n```\n- create a app/code/BDC/Minventory/Block/Adminhtml/Product/Edit/Button/Save.php\n```    \n\u003c?php\n\nnamespace BDC\\Minventory\\Block\\Adminhtml\\Product\\Edit\\Button;\n\nclass Save extends \\Magento\\Backend\\Block\\Template implements \\Magento\\Framework\\View\\Element\\UiComponent\\Control\\ButtonProviderInterface\n{\n    public function getButtonData() {\n        return [\n            'label' =\u003e __('Save'),\n            'class' =\u003e 'save primary',\n            'data_attribute' =\u003e [\n                'mage-init' =\u003e ['button' =\u003e ['event' =\u003e 'save']],\n                'form-role' =\u003e 'save',\n            ],\n            'sort_order' =\u003e 20,\n        ];\n    }\n}\n\n```\n- create a app/code/BDC/Minventory/Ui/Component/Listing/Columns/Resupply.php\n```    \n\u003c?php\n\nnamespace BDC\\Minventory\\Ui\\Component\\Listing\\Columns;\n\nclass Resupply extends \\Magento\\Ui\\Component\\Listing\\Columns\\Column\n{\n    protected $urlBuilder;\n\n    public function __construct(\n        \\Magento\\Framework\\View\\Element\\UiComponent\\ContextInterface $context,\n        \\Magento\\Framework\\View\\Element\\UiComponentFactory $uiComponentFactory,\n        \\Magento\\Framework\\UrlInterface $urlBuilder,\n        array $components = [],\n        array $data = []\n    )\n    {\n        $this-\u003eurlBuilder = $urlBuilder;\n        parent::__construct($context, $uiComponentFactory, $components, $data);\n    }\n\n    public function prepareDataSource(array $dataSource)\n    {\n        if (isset($dataSource['data']['items'])) {\n            $storeId = $this-\u003econtext-\u003egetFilterParam('store_id');\n\n            foreach ($dataSource['data']['items'] as \u0026$item) {\n                $item[$this-\u003egetData('name')]['resupply'] = [\n                    'href' =\u003e $this-\u003eurlBuilder-\u003egetUrl(\n                        'minventory/product/resupply',\n                        ['id' =\u003e $item['entity_id'], 'store' =\u003e $storeId]\n                    ),\n                    'label' =\u003e __('Resupply'),\n                    'hidden' =\u003e false,\n                ];\n            }\n        }\n\n        return $dataSource;\n    }\n}\n\n```\n- create a app/code/BDC/Minventory/Ui/DataProvider/Product/Form/ProductDataProvider.php\n```  \n\u003c?php\n\nnamespace BDC\\Minventory\\Ui\\DataProvider\\Product\\Form;\n\nclass ProductDataProvider extends \\Magento\\Ui\\DataProvider\\AbstractDataProvider\n{\n    protected $loadedData;\n    protected $productRepository;\n    protected $stockRegistry;\n    protected $request;\n\n    public function __construct(\n        string $name,\n        string $primaryFieldName,\n        string $requestFieldName,\n        \\Magento\\Catalog\\Model\\ResourceModel\\Product\\CollectionFactory $collectionFactory,\n        \\Magento\\Catalog\\Api\\ProductRepositoryInterface $productRepository,\n        \\Magento\\CatalogInventory\\Api\\StockRegistryInterface $stockRegistry,\n        \\Magento\\Framework\\App\\RequestInterface $request,\n        array $meta = [], array $data = []\n    )\n    {\n        parent::__construct($name, $primaryFieldName, $requestFieldName, $meta, $data);\n        $this-\u003ecollection = $collectionFactory-\u003ecreate();\n        $this-\u003eproductRepository = $productRepository;\n        $this-\u003estockRegistry = $stockRegistry;\n        $this-\u003erequest = $request;\n    }\n\n    public function getData()\n    {\n        if (isset($this-\u003eloadedData)) {\n            return $this-\u003eloadedData;\n        }\n\n        $id = $this-\u003erequest-\u003egetParam('id');\n        $product = $this-\u003eproductRepository-\u003egetById($id);\n        $stockItem = $this-\u003estockRegistry-\u003egetStockItemBySku($product-\u003egetSku());\n\n        $this-\u003eloadedData[$product-\u003egetId()]['minventory_product'] = [\n            'stock' =\u003e __('%1 | %2', $product-\u003egetSku(), $stockItem-\u003egetQty()),\n            'qty' =\u003e 10\n        ];\n\n        return $this-\u003eloadedData;\n    }\n}\n\n```\n- create a app/code/BDC/Minventory/Ui/DataProvider/Product/ProductDataProvider.php\n\n```\n\u003c?php\n\nnamespace BDC\\Minventory\\Ui\\DataProvider\\Product;\n\nclass ProductDataProvider extends \\Magento\\Ui\\DataProvider\\AbstractDataProvider\n{\n    protected $collection;\n\n    public function __construct(\n        string $name,\n        string $primaryFieldName,\n        string $requestFieldName,\n        \\Magento\\Catalog\\Model\\ResourceModel\\Product\\CollectionFactory $collectionFactory,\n        array $meta = [],\n        array $data = []\n    )\n    {\n        parent::__construct(\n            $name,\n            $primaryFieldName,\n            $requestFieldName,\n            $meta,\n            $data\n        );\n\n        $this-\u003ecollection = $collectionFactory-\u003ecreate();\n\n        $this-\u003ejoinQty();\n    }\n\n    public function getData()\n    {\n        if (!$this-\u003egetCollection()-\u003eisLoaded()) {\n            $this-\u003egetCollection()-\u003eload();\n        }\n\n        // By default parent's getData already does $this-\u003egetCollection()-\u003etoArray();\n        // However, this is not enough for product collection as we need the \"totalRecords and items\" structure\n        $items = $this-\u003egetCollection()-\u003etoArray();\n\n        return [\n            'totalRecords' =\u003e $this-\u003egetCollection()-\u003egetSize(),\n            'items' =\u003e array_values($items),\n        ];\n    }\n\n    protected function joinQty()\n    {\n        if ($this-\u003egetCollection()) {\n            $this-\u003egetCollection()-\u003ejoinField(\n                'qty',\n                'cataloginventory_stock_item',\n                'qty',\n                'product_id=entity_id'\n            );\n        }\n    }\n}\n\n\n```\n\n- Output\n\n![](docs/minventoryList.png)\n![](docs/resupplyStock.png)\n![](docs/resupplyaddAfter.png)\n![](docs/massResuply.png)\n\n\n### Ref\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbdcrops%2Fmodule-minventory","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbdcrops%2Fmodule-minventory","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbdcrops%2Fmodule-minventory/lists"}