How to add product qty and product price store wise progrmatically in magento 2Update price attribute and save attributeProducts are not showing on category and search resultHow to create/update bulk of products at a time programmaticallyAvailable Inventory not showing with product infoauto save in stock if qty greater than 0Magento 2: Add a product to the cart programmaticallyHow to Update Magento 2 configurable child products price by REST APIMagento 2.2.5: Add, Update and Delete existing products Custom OptionsOnly 1 product adding to order when creating orders programmatically in Magento 2How to add category Path when creating product progrmatically in magento 2
C++ debug of nlohmann json using GDB
On a tidally locked planet, would time be quantized?
What was the exact wording from Ivanhoe of this advice on how to free yourself from slavery?
New brakes for 90s road bike
Is it better practice to read straight from sheet music rather than memorize it?
How should I respond when I lied about my education and the company finds out through background check?
Are paving bricks differently sized for sand bedding vs mortar bedding?
Why does the Sun have different day lengths, but not the gas giants?
Pre-modern battle - command it, or fight in it?
Why Shazam when there is already Superman?
How do you respond to a colleague from another team when they're wrongly expecting that you'll help them?
dpdt switch to spst switch
What if a revenant (monster) gains fire resistance?
lightning-datatable row number error
Why can Carol Danvers change her suit colours in the first place?
A social experiment. What is the worst that can happen?
Not using 's' for he/she/it
Strong empirical falsification of quantum mechanics based on vacuum energy density
Does a 'pending' US visa application constitute a denial?
Aragorn's "guise" in the Orthanc Stone
Multiplicative persistence
How do you make your own symbol when Detexify fails?
Is aluminum electrical wire used on aircraft?
The screen of my macbook suddenly broken down how can I do to recover
How to add product qty and product price store wise progrmatically in magento 2
Update price attribute and save attributeProducts are not showing on category and search resultHow to create/update bulk of products at a time programmaticallyAvailable Inventory not showing with product infoauto save in stock if qty greater than 0Magento 2: Add a product to the cart programmaticallyHow to Update Magento 2 configurable child products price by REST APIMagento 2.2.5: Add, Update and Delete existing products Custom OptionsOnly 1 product adding to order when creating orders programmatically in Magento 2How to add category Path when creating product progrmatically in magento 2
I want to create product progrmatically.
product creating section is done, after creating the product i want to update the product qty and price store wise.
I have following array which return me the qty and price store wise.
Array
(
[0] => 1-13-45
[1] => 2-12-22
)
In my helper i have below function to update the qty and price store wise.
public function __construct(
MagentoCatalogModelProductRepository $productRepository)
$this->_productRepository = $productRepository;
public function updateStockAndPricesByStore($product_id,$store_data)
foreach($store_data as $store)
$store_datas = explode("-",$store);
$store_id = $store_datas[0];
$qty = $store_datas[1];
$price = $store_datas[2];
$new_product = $this->_productRepository->getById($product_id, false, $store_id);
$new_product->setPrice($price);
$new_product->save();
$new_product->setStockData(
array(
'use_config_manage_stock' => 0,
// checkbox for 'Use config settings'
'manage_stock' => 1, // manage stock
'is_in_stock' => 1, // Stock Availability of product
'qty' => $qty // qty of product
)
);
//End for each
//End of function updateStockAndPricesByStoree
I can get the product name after getById function like this
echo $new_product->getName()
But unable to update the product qty and product price by using this code.
How can i update the product price and stock programatically?
product magento2.2 price programmatically inventory
add a comment |
I want to create product progrmatically.
product creating section is done, after creating the product i want to update the product qty and price store wise.
I have following array which return me the qty and price store wise.
Array
(
[0] => 1-13-45
[1] => 2-12-22
)
In my helper i have below function to update the qty and price store wise.
public function __construct(
MagentoCatalogModelProductRepository $productRepository)
$this->_productRepository = $productRepository;
public function updateStockAndPricesByStore($product_id,$store_data)
foreach($store_data as $store)
$store_datas = explode("-",$store);
$store_id = $store_datas[0];
$qty = $store_datas[1];
$price = $store_datas[2];
$new_product = $this->_productRepository->getById($product_id, false, $store_id);
$new_product->setPrice($price);
$new_product->save();
$new_product->setStockData(
array(
'use_config_manage_stock' => 0,
// checkbox for 'Use config settings'
'manage_stock' => 1, // manage stock
'is_in_stock' => 1, // Stock Availability of product
'qty' => $qty // qty of product
)
);
//End for each
//End of function updateStockAndPricesByStoree
I can get the product name after getById function like this
echo $new_product->getName()
But unable to update the product qty and product price by using this code.
How can i update the product price and stock programatically?
product magento2.2 price programmatically inventory
add a comment |
I want to create product progrmatically.
product creating section is done, after creating the product i want to update the product qty and price store wise.
I have following array which return me the qty and price store wise.
Array
(
[0] => 1-13-45
[1] => 2-12-22
)
In my helper i have below function to update the qty and price store wise.
public function __construct(
MagentoCatalogModelProductRepository $productRepository)
$this->_productRepository = $productRepository;
public function updateStockAndPricesByStore($product_id,$store_data)
foreach($store_data as $store)
$store_datas = explode("-",$store);
$store_id = $store_datas[0];
$qty = $store_datas[1];
$price = $store_datas[2];
$new_product = $this->_productRepository->getById($product_id, false, $store_id);
$new_product->setPrice($price);
$new_product->save();
$new_product->setStockData(
array(
'use_config_manage_stock' => 0,
// checkbox for 'Use config settings'
'manage_stock' => 1, // manage stock
'is_in_stock' => 1, // Stock Availability of product
'qty' => $qty // qty of product
)
);
//End for each
//End of function updateStockAndPricesByStoree
I can get the product name after getById function like this
echo $new_product->getName()
But unable to update the product qty and product price by using this code.
How can i update the product price and stock programatically?
product magento2.2 price programmatically inventory
I want to create product progrmatically.
product creating section is done, after creating the product i want to update the product qty and price store wise.
I have following array which return me the qty and price store wise.
Array
(
[0] => 1-13-45
[1] => 2-12-22
)
In my helper i have below function to update the qty and price store wise.
public function __construct(
MagentoCatalogModelProductRepository $productRepository)
$this->_productRepository = $productRepository;
public function updateStockAndPricesByStore($product_id,$store_data)
foreach($store_data as $store)
$store_datas = explode("-",$store);
$store_id = $store_datas[0];
$qty = $store_datas[1];
$price = $store_datas[2];
$new_product = $this->_productRepository->getById($product_id, false, $store_id);
$new_product->setPrice($price);
$new_product->save();
$new_product->setStockData(
array(
'use_config_manage_stock' => 0,
// checkbox for 'Use config settings'
'manage_stock' => 1, // manage stock
'is_in_stock' => 1, // Stock Availability of product
'qty' => $qty // qty of product
)
);
//End for each
//End of function updateStockAndPricesByStoree
I can get the product name after getById function like this
echo $new_product->getName()
But unable to update the product qty and product price by using this code.
How can i update the product price and stock programatically?
product magento2.2 price programmatically inventory
product magento2.2 price programmatically inventory
asked yesterday
MujahidhMujahidh
1,41012036
1,41012036
add a comment |
add a comment |
0
active
oldest
votes
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%2f266973%2fhow-to-add-product-qty-and-product-price-store-wise-progrmatically-in-magento-2%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
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%2f266973%2fhow-to-add-product-qty-and-product-price-store-wise-progrmatically-in-magento-2%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