Questions tagged [programmatically]

Denotes questions related to making changes to the Magento platform programmatically, rather than via the admin interface.

Filter by
Sorted by
Tagged with
0
votes
2answers
21 views

Magento 2 Set Shipping Method Programatically

I am trying to set Shipping Method Progrmatically but getting following error. The shipping method is missing. Select the shipping method and try again. foreach ($quote->getAllAddresses() as $...
0
votes
1answer
23 views

Magento2: Create customers programmatically and associate to multiple websites

I have written a customer import which works just fine. Now the requirement has changed .. the Magento instance runs now multiple stores / websites and i need to change the customer import so that the ...
0
votes
1answer
22 views

Magento 2: How to create multi-line order with same SKU programmatically?

$product ->setPrice($price) ->setSpecialPrice($price) ->setTierPrice([]) ->...
0
votes
0answers
45 views

Error in creating Order Programmatically, Magento 2

I am creating order at controller action, just to test if its working or not as: class Save extends \Magento\Framework\App\Action\Action { /** * @param Magento\Framework\App\Helper\Context $...
0
votes
0answers
24 views

Is it possible to Set Multi Currency for Custom Prices programmatically magento 2?

I am finding a solutions to work multi currency concepts for custom pricing programmatically because default magento do not support this feature. By Default Magento 2 Flow: STORES > Configuration >...
0
votes
1answer
43 views

How to add Home Page url key for all scopes programmatically using Recurring.php magento 2

I tried to add Home Page URL key programmatically using Recurring.php Normally from Magento Admin backend: STORES -> GENERAL -> Web -> Default Pages -> Default Web URL: I tried using Vendor/...
0
votes
0answers
21 views

Adding two virtual products with different option in orders

I'm creating order programmatically. I'm creating two different orders. The first one is sended to an external API and the second one is saved in Magento. I have this problem : If I'm having twice ...
0
votes
1answer
35 views

Magento 2: Change quote base currency programmatically?

I am creating orders programmatically in Magento 2 and want to change the order base currency as well as current currency to my custom currency, irrespective to currency available in Store as I don't ...
1
vote
1answer
36 views

How add category programmatically magento 2.3? [duplicate]

I would like to create categories programmatically in magento 2.3 Can you help me to provide us code? Thanks in advance!
0
votes
2answers
50 views

Magento 2 How to update block programmatically?

How can i update block content programmatically?
1
vote
1answer
32 views

What does “setIsSuperMode” do on Quote Object in Magento 2?

I am creating a Quote programmatically, I have found a field IsSuperMode on Quote object. What effect does it have on the Quote ? Class: /Magento/Backend/Model/Session/Quote.php https://github.com/...
0
votes
2answers
32 views

How to create backorder programatically magento 2?

I am using the following code to add products to Quote object which throws an error if the product is out of stock. /** @var \Magento\Catalog\Model\Product $product */ $product->setTaxClassId($...
0
votes
1answer
22 views

How to Insert Data in magento 2 database table programatically

We want to insert data in database table. My site is in magento 2. Any one help me for insert data in database table. namespace Agtech\Productstockupdate\Block\Index; class Index extends \Magento\...
2
votes
2answers
145 views

magento2 send email programmatically without template

I want to send custom email programmatically without any template. In magento 1, I used below script to do same thing. $mail = Mage::getModel('core/email'); $mail->setToName('xxx'); $mail->...
3
votes
3answers
61 views

Remove existing and assign new categories to existing product while updating it programmatically in magento 2

How can I remove existing and assign new categories to product programmatically in magento 2 while updating product data. <?php $newCategoryIds = array(5,6); $existingProductId = 25; $...
1
vote
1answer
38 views

Update Product Attribute Data for All Store Views

I'm trying to update a certain attribute of all of my products programmatically. So far, I've used Magento\Catalog\Model\ResourceModel\Product\CollectionFactory and iterating through the products, ...
2
votes
0answers
20 views

Magento 2 place order in custom controller (difference between placeOrder and submit)

In How to create order programmatically in Magento 2? it shows two methods on how to place a quote as an order. The first method uses $order = $this->quoteManagement->submit($quote); via \...
2
votes
2answers
30 views

remove coupon code from cart

I want to delete the coupon code programmatically. My code is: $cart = $this->quoteRepository->getActive($cartId); if(isset($response_json['errorMessage']) || $json_response['status']['...
0
votes
0answers
23 views

How to call Magento2 mview reindexer programmatically

I have line of code which schedule full or partial reindex cron job. using Trigger::REINDEX_SCOPE_PARTIAL and Trigger::REINDEX_SCOPE_FULL parameter. public function restoreIndexers($reindex = false, ...
0
votes
1answer
60 views

Unique constraint violation found when creating order programmatically

I've been trying to create an order programatically in Magento 2.3 and the order is created but my code dies and I get the error : "Unique constraint violation found". What do I need to add or change?...
0
votes
2answers
58 views

Fastest way to load category and save programmatically in Magento 2

I want to load all collection in Magento 2 and save one by one programmatically. is there any faster way to do so. I tried below code for one category use Magento\Framework\App\Bootstrap; include('...
0
votes
0answers
57 views

magento 2 create shipment programmatically with inventory source selection

I have created order shipment programmatically with below code but I don't know how to select SourceCode when multiple sources available in Magento backend. public function execute() { $...
1
vote
0answers
39 views

How to Create Multiple shipment programmatically in magento 2

If user added 2 different product in order, want to create two shipment on ready for dispatch button , programmatically .
0
votes
1answer
26 views

Update product visibility to search only programmaticallly. $product->setVisibility(3) does not work, break the script

I have this script to update product attributes, everything else run fine until i added this line below of code to update visibility to search only. I know i can update it through catalog product grid,...
0
votes
1answer
40 views

Add Product to cart error: invalid request for adding product to quote

I have a plugin and i want to add a product to the actual cart. This is my code: $productId = 2; $params = array( 'form_key' => $this->formKey->...
0
votes
0answers
32 views

Change store view using code when starting session - Magento 2

I want to make a change of store view through code. I have created the next plugin for when the user logs in the system makes a change of store view, but the change is not maintained, I want to switch ...
0
votes
2answers
38 views

Creating a product programmatically without deprecated functions

I have the following code which creates a product programmatically but it uses deprecated functions eg the save Therefore my question is how do you create a product programmatically without using ...
1
vote
1answer
28 views

How to Bulk import Product Reviews in Magento 1.9?

I have a list of reviews with email id, how can I bulk import Product Reviews into Magento?
0
votes
1answer
22 views

Getting error on attributeResource save

I'm trying to add an attribute called orchestra_id to Order and OrderAddress. I've made a plugin who have been already activated. So I've create an Setup\UpgradeData model. This is what it look like: ...
2
votes
1answer
53 views

How to add tracking number to ShipOrderInterface programmatically

How can I passed the tracking number to the Model \Magento\Sales\Api\ShipOrderInterface. The method is working with a empty array. this is the code I've made for testing, but it's not working: <?...
1
vote
0answers
21 views

Magento2.3 how to add custom option of product when create order programatically? [duplicate]

I am using Magento2.3 I need to how to add custom option of product when create order programmatically? I used below code for add custom option to product but it is not working $product = $om->...
2
votes
1answer
29 views

M2 | How to set default store view of product while creating the product programmatically?

I am creating simple product programmatically, but for displaying it on frontend I need to edit product from admin side and set its view from All Store Views to Default Store View Mannually, ...
1
vote
2answers
37 views

How to get all processing and pending orders programmatically?

How can I get a list of all the orders in processing and pending status in Magento 2?
1
vote
0answers
22 views

Optimized way to get Total Delivered Items in Mageno 2

I am looking for an optimized way to get the total number of shipped/delivered items from the entire purchase history of a customer. This is the code i am using right now. /* $this->order = ...
0
votes
0answers
40 views

Additional column in orders

I would like to add an additional column in the Orders where all orders are visible called Company name. The information that will be displayed in this column will come from a drop-down menu located ...
0
votes
1answer
37 views

Add options to quote programmaticaly

I'm creating quote and order programmaticaly. I can't figure out why options product are not added to my order / quote. See : $superAttr = $item["super_attribute"]; if(!empty($superAttr)){ $...
0
votes
1answer
22 views

Can't create custom attribute for order_address

I need to create a custom attribute on the order address to stock my ERP id of the address for a syncing purpose. I've tried to create a Eav in Maru3l/SyncOrchestra/Setup/InstallData.php. I don't see ...
0
votes
1answer
42 views

Need to run Reindex command in Controller (programmatically) in Magento 2 [duplicate]

I need to run command php bin/magento indexer:reindex in Controller.
1
vote
1answer
111 views

Sending order confirmation email in magento 2 programmatically

Normally I would do something like <?php use \Magento\Sales\Model\Order\Email\Sender\OrderSender; use \Magento\Sales\Model\Order; class MyClass { private $orderSender; private $order; ...
0
votes
0answers
42 views

Custom Product Attribute values editable through Dashboard

I created a module that install and upgrades custom product attribute programmatically. It works as intended, however, when viewing the attribute through admin dashboard, I am unable to make any ...
0
votes
0answers
35 views

Magento 2.2 - Custom options are not saved programmatically on cart update

Initially, while adding an item to cart the custom options and other details are saved successfully to cart. When reupdating the cart with updated custom options are not saved in cart programmatically....
1
vote
1answer
76 views

How to duplicate sales rule programmatically in Magento2

Im try to duplicate some salesrule exist, i can duplicate this, but i can't use setConditionsSerialized and setActionsSerialized with getCondition and getActionCondition, its dont working use ...
0
votes
2answers
150 views

How to set List Mode(backend configuration) programmatically for category page magento 2?

Actually i want to set list/grid mode(List Mode) configuration values for category page programmatically not from magento admin backend.if anyone have any idea please guide me.
0
votes
1answer
126 views

Send Sales Order mail to multiple account Programatically

In this screenshot you can see sales order mail sending to multiple acounts . and It work good mail sending to all accounts which mention in Send Order Email Copy To This is hard code to give ...
0
votes
0answers
13 views

Coupon code being applied only to the first product in cart insead of whole cart

A coupon code is generated programmatically on a particular day. The coupon code when applied shows the correct discount amount and even the checkout shows the correct discount amount, but when the ...
0
votes
1answer
148 views

How to call Web API call inside custom module Magento 2

How can we call Web API in a custom module? I have a third party module, in which they are sending a request with API calls. I have custom functionality where I have to redirect my page to that Web ...
0
votes
0answers
25 views

How to add product qty and product price store wise 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 ...
2
votes
2answers
155 views

How to set the category ids to a products from category path?

I want to progrmmatically create products from a xml. Ex : I am getting the product categories as like below. Default Category/Beer , Default Category/Beer /CRAFT, Default Category/Beer /CRAFT/...
1
vote
0answers
19 views

How to add category Path when creating product progrmatically in magento 2

I want to create products programatically by reading an xml file. Reading from xml, and creating product part is completed. I have no idea how to assign the products to category. This is my xml node ...
1
vote
0answers
119 views

Add multiple products in cart programatically magento 2

I am trying to add multiple products in cart programmatically. This below code is working properly but I need to set quantity dynamically. If quantity is not set that product to be skipped without ...