Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [programmatically]

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

0
votes
1answer
23 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
26 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
12 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() { $...
0
votes
0answers
15 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
21 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
22 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
25 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
21 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
20 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
19 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
20 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
15 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
23 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
31 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
33 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
19 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
33 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
43 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
29 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
26 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
46 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
89 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
64 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
89 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
20 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
99 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
15 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
91 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 ...
1
vote
1answer
51 views

How to apply Coupon on the Specific Products in Magento 2?

I want to apply the coupon on the specific product I tried: use Magento\SalesRule\Model\Rule; public function __construct( \Magento\Framework\App\Helper\Context $helpercontext, Rule $rule, )...
4
votes
1answer
61 views

How to set cms block to category in Magento 2 programmatically?

I would like to add CMS block to a category programmatically, how to achieve it?
0
votes
1answer
33 views

Only 1 product adding to order when creating orders programmatically in Magento 2

I am in a process of creating orders programatically in Magento 2. below is my code: <?php namespace Eight65media\MpowerSync\Helper; use \Magento\Framework\App\Helper\AbstractHelper; class Data ...
1
vote
0answers
31 views

Issue in pragmatically create orders in magento 2

I want to create orders pragmatically by getting the data from xml. Reading data from xml part is done. when creating order steps i am getting this error. Parse error: syntax error, unexpected '$...
0
votes
1answer
109 views

Magento 2 programmatically create cart rule with condition issue on setOperator

As per my requirement am creating the cart rule programmatically, for that i am reviewed the following code and implemented in my local public function createRule() { $price = 100; $sku = '...
0
votes
3answers
101 views

Magento 2 - How Can I Update Catalog Product Price Programmatically in Frontend and Add Product to Cart With New Price?

I create one Module and make a custom form which is display in the catalog product view page. when the customer change option from dropdown then the product price will change and also that updated ...
1
vote
1answer
42 views

Magento 2 - Create or change customer to set customerID

Is there a way to create a customer programmatically and set the customer ID? Or is there a way to change it afterwards? We are getting customer data from a central system in csv format and would ...
2
votes
1answer
42 views

Magento programmatically refresh statistics. - Magento1

How to refresh statistics programmatically in Magento 1?
0
votes
2answers
50 views

Login by email without password

I would login by email only , without password. I have Read these two Posts but it not works for me. Programmatically login a user https://blog.ancud.de/home/-/blogs/magento-how-to-login-a I use ...
1
vote
0answers
55 views

Magento 2.2.6: Programatically updating product custom options

I am working on custom script to update product custom options. $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $_product = $objectManager->create('Magento\Catalog\Api\...
0
votes
0answers
13 views

How to edit category in Magento 1 using PHP using path (Not ID)

I need to be able to revise Magento 1 categories externally. When products are created using Magmi it creates the category, during the process, I store the path used to create the category. I want to ...
0
votes
0answers
56 views

How to add bundled product to cart programmatically in Magento 1.9?

I am trying to add the bundled product to cart programmatically, Still, I didn't get any solution. I have tried to add the configurable product to cart, That is working fine. this is the code I have ...
0
votes
1answer
80 views

setPrice() not working

I want to change the price of a particular product via a module but it is not working. I have searched and found a lot of solutions but none is working for me. I'm relatively new to Magento, I'm ...
1
vote
0answers
132 views

How to speed up creating orders programmatically in Magento 2?

I have a script that creates orders in Magento 2. <?php /** * ExtendedRma Helper */ namespace Company\Module\Helper; class CreateOrder extends \Magento\Framework\App\Helper\AbstractHelper { ...
0
votes
0answers
69 views

Magento 2: Create Customer Attribute in Custom Save Controller

I have a custom module with a custom form in admin. On this form save action, I want to create customer attribute programmatically with the data fetched from the custom form. How can I do it. ...
0
votes
1answer
134 views

Programmatically Add Products to Store View?

We have a multi-store with a bunch of products. For certain categories in specific store views, I'd like to set all products to be in a particular store. Advice on how to achieve this would be ...
1
vote
1answer
210 views

Magento 2: Login user programmatically showing wrong default header message “Default welcome msg!” instead of showing “Welcome, user!”

When you login to Magento 2.2.6 programmatically with code below, header show default message "Default welcome msg!" instead of "Welcome, user!" // Load customer session $customerSession = $...
0
votes
3answers
79 views

How to programmatically create multiple CMS pages at once?

I am working in Magento 2 and I am needing to create multiple CMS pages all at one time. I am trying to set up an Install script to do this all at once. Every tutorial and search that I look up shows ...
1
vote
0answers
245 views

Magento 2.2.5: Add, Update and Delete existing products Custom Options

I am working on updating custom options of an existing product programatically when admin click product save button - I have done below code to full fil my desire - app/code/Namespace/Module/etc/...