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
0answers
11 views

Change order price after selecting payment method

How can I change the total payment value according to payment methods programmatically? For eg. A product has price $100 then If someone order this product and choose Check / Money Order the price ...
0
votes
1answer
31 views

Products are not updating programmatically Magento2

I'm trying to update product details by this code - public function updateProducts(){ $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); // instance of object manager ...
0
votes
1answer
15 views

Magento 2: What's the difference between Store and Group?

I want to create a Store programatically, but if it already exists, then return the existing store. So far my code looks like this: private function _getStore($website, $storeName, $storeCode) { ...
2
votes
4answers
135 views

faster way to update attributes/ update product programmtically with stock data in Magento 2?

I have this code but Anybody tell me faster way to update products. This below code takes much time. So any alternative solution for to save product in fast way and Can I also put sleep function at ...
0
votes
2answers
27 views

Add products to cart using \Magento\Quote\Api\CartRepositoryInterface

I'm trying to add products to cart programmatically using \Magento\Quote\Api\CartRepositoryInterface since \Magento\Checkout\Model\Cart is already deprecated. My code is successfully being inserted in ...
1
vote
0answers
7 views

magento 2: value not saved for attribute by programmatically

I am trying to save some values in my attribute by programmatically. My attribute name is storage. type is dropdown I am trying to save values like 32GB or 16GB this values do not saved but if I used '...
1
vote
2answers
20 views

Can't get order with OrderRepositoryInterface

I have an order in sales_order with entity_id = 1 and increment_id = 000000001. Both ways of trying to get this order fails with the same response. $searchCriteria = $this->searchCriteriaBuilder ...
1
vote
1answer
27 views

Unlink simple product variant from configurable product programmatically in magento 2

I want to unlink some (not all) simple products from configurable product. I don't want to delete simple products, I just want to unlink from the main configurable product programmatically.
0
votes
2answers
92 views

Magento 2 - How Can I Send Success and Error in JSON and from Frontend update product price and enable/'disable?

Ajax runs on page load i want to run it on button click. I create one Module and make a custom tab which is display some product with name and price and if the product is enable/disable. I want that ...
0
votes
1answer
24 views

How to make cache for specific url by programmatically?

I need suggestion. I do not have an Idea to set cache for specific page url. For example I have an Url : http://127.0.0.1/magento234/women/tops-women/jackets-women.html How can I set full page cache ...
0
votes
0answers
47 views

Set shipping method programatically Magento 2 return 0

I am setting the Shipping Method programatically in the observer checkout_cart_add_product_complete, the code works fine. I navigate to the cart page, I am able to see the shipping price in the ...
0
votes
1answer
14 views

Problem in retrieving orders with “processing” status

I am using the code below to filter orders by their status and after to change it to complete use Psr\Log\LoggerInterface; class OrderStatus { /** * @var \Magento\Sales\Api\...
0
votes
0answers
23 views

Magento 2 + Programatically create product issue

<?php declare(strict_types=1); namespace Test\Xyz\Model\SampleData; use Exception; use Magento\Catalog\Api\Data\ProductInterfaceFactory; use Magento\Catalog\Api\ProductRepositoryInterface; use ...
0
votes
0answers
14 views

Bundle_option_qty not working, with programmatically add bundle product to cart (magento 2.3.2)

I would like to add a bundle product to cart programmatically, however i'm experiencing a problem with the bundle_option_qty. I can change the selection of the bundle option, however the code is ...
0
votes
1answer
43 views

Magento 2.3: Re-save all products programatically [closed]

I need to re-save all products programatically without modifying any attribute. (Only re-save) How to do that ?
1
vote
0answers
19 views

Store wih diferent languages have broken images after programmatically product import

I have a script running in cron to import products. This import creates simple products and then creates a configurable one with all these simple ones as children of that. During this process, I ...
0
votes
0answers
157 views

Error “DDL statements are not allowed in transactions” while Reindexing programmatically using Event Observer Magento 2.3.0

Actually i am trying to reindex category data while saving category from backend but i am getting an error DDL statements are not allowed in transactions in log file while reindexing ...
1
vote
2answers
58 views

How to display programmatically created custom options in admin order details

I created 4 programmatically custom options. It is successfully display in cart page and also make successful order. I created module for that. Here its code. path : vendor/addtocart/controller/index/...
0
votes
0answers
38 views

Can we Create Product Attributes Programmatically without using setup Script in magento 2.3?

Can you help to Create Product Attributes Programmatically without using setup Script in magento 2.3 ?
0
votes
0answers
20 views

How to Create Product attributes Programmatically from CSV in magento 2.3?

I have list of product custom attributes in a CSV. How to read these attributes from CSV and create them in Magento 2.3. Note : I don't want to use setup script for creating these attributes because I ...
0
votes
0answers
106 views

Importing Date Attributes in DD/MM/YYYY format

When importing products with date fields in format dd/mm/YYYY it throws this error: Value for 'special_to_date' attribute contains incorrect value in row(s): 1, 2, 3 From reading around I see ...
0
votes
1answer
30 views

What is difference between creating custom attribute programmatically and via admin in magento 2?

Creating an attribute in the back end is easy, then why to create it as programmatically? I like to know what is the difference between these two.
0
votes
1answer
44 views

Magento 2 : add tier price programatically for all customer Group

How to add Tier Price programatically for all customer group Tried below not working. As ALL GROUP id is 32000; $sku = "test"; $customerGroupId = 32000; $price = 5.5; $qty = 2; $tierPrice = $obj-&...
0
votes
0answers
28 views

How to Add Size Attribute In Configuration Product Create Programatically For Following Code?

<?php error_reporting(1); set_time_limit(0); ini_set('memory_limit', '2048M'); use Magento\Framework\App\Bootstrap; /** * If your external file is in root folder */ require __DIR__ . '/app/...
0
votes
1answer
12 views

how to het customer pick date for electron product, example, amusement park ticket

I'm trying to sell tickets electronically. Consider like an amusement park, or parking lot tickets. No worries about assigned seats or limited dates / times. I can handle checking if it is sold out, ...
0
votes
0answers
75 views

Magento 2 programmatically update products by processing feed (cron job)

I have looked everywhere high and low, and tried every "solution" I could find, but could not figure out what's wrong with my code. We have an XML feed which gets imported to a local folder, and then ...
0
votes
1answer
62 views

Magento2: How to disabled coupon code programmatically from the cart and checkout page?

I want to disabled coupon code programmatically from the cart and checkout page if the condition is true. Please help me.
0
votes
0answers
8 views

M2.3.3 : 500 on product creation page after adding attribute programatically

I am adding product attribute programmatically the following way: use Magento\Framework\App\Bootstrap; require '/www/public_html/app/bootstrap.php'; $params = $_SERVER; $bootstrap = Bootstrap::create(...
0
votes
1answer
38 views

setData does not set attributes values

I am creating simple products and try to set some attribute values $attributeSetId = $product->getDefaultAttributeSetId(); $product->setSku($sku); // Set your sku here $product->setName($...
0
votes
0answers
21 views

Magneto 2 :Delete DB fields while admin disable a module from backend

Created a module ,in which created some custom product attributes for products.Thus added few new rows in eav_entity table using InstallData.php file. Everything working fine. But even I disabled the ...
0
votes
0answers
47 views

How to assign simple product to configurable product programatically in magento 2?

I want to know any script where we can assign a simple product to configurable products with just add product Id. can anyone give me script for it?
1
vote
0answers
31 views

Magento 2.3: Order Create Programatically Script Allowed memory exhausted

I am working on creating orders dynamically using custom magento script , got reference from How to create order programmatically in Magento 2? now when I run script, after making 10-15 orders, first ...
1
vote
3answers
281 views

How to pass the value and call js function from template.html using knockout js in(in checkout page) Magento 2?

I have to call and pass value to the js function(showPopup())from the template(when clicking the Verify OTP button). How to achieve this?. But now i am not able to call the js function. layout file &...
1
vote
0answers
17 views

Custom Shipping Method as fallback

I've created a shipping method in magento2 . It checks if there is any oversize product in cart and if the package weight is more than 31.5 kg. How can I set this shipping method as default if ...
0
votes
0answers
20 views

Magento 2 Addtocart Group product programatically

I am facing the problem with the Addtocart group product. Can anyone suggest me the code? I have tried as a simple product but it's not working as well try with below code but that did not work out ...
1
vote
3answers
65 views

How Reindex and Reset programmatically in magento 2?

I Need to reindex and reset the indexer programmatically using external script from magento root. How can i achieve this.Is there a Way to do this.? I am new in magento. Please help me. Thanks in ...
2
votes
1answer
130 views

Add images to product description content programatically in Magento2

I want to add images to my product description content block but I don't want these specific images to appear in the product gallery ('image', 'small_image', 'thumbnail'). To add regular images I do ...
0
votes
0answers
122 views

How to set the option swatch text by API in Magento 2

I am currently trying to set an option in a swatch text attribute: $headers = array(); $headers[] = "Content-Type: application/json"; $headers[] = "authorization: Bearer xxx"; $body = '{ "option": {"...
1
vote
0answers
20 views

How to add existent options inside product options

I trying to add simple products and after associate these products in a configurable product, but some options of these products can't be exists. So, I add options using EVA config and return id of ...
2
votes
1answer
425 views

Magento 2.3 Custom Module Send Email Programmatically with image attachment

I want to send email with the image attachment into custom module Programmatically. How to do this? Thanks in Advance
0
votes
0answers
41 views

How to get the shipping flat rate programmatically?

Although I expected this not to be a problem, I now find myself stuck without knowing how to retrieve the Shipping Flat Rate, that I've defined in the admin panel, programmatically so to have it ...
0
votes
2answers
514 views

Magento 2: Create order from quote without quote submit

I want to create order from quote programmatically without submit quote. Because if customer redirect to failure page then we have one button like Make payment which redirect to customer on checkout ...
1
vote
1answer
23 views

How to programmatically set description in simple associated products?

I need set description in all associated products of specific configurable product and with this code all it's ok except part of code where I insert description in associated products on database. ...
0
votes
0answers
16 views

How can i set new attribute from quote item

I added a new column into sales_order_item i created programaticly order create and i would like to use this column in the order as attribute. This code add items to quote. Quote use sales_order_item ...
3
votes
4answers
2k views

How to update product qty and Stock Status update programmatically by product id : Magento 2

I want to update product qty and change Stock Status as in stock by programmatically by product id. I dont want to insert new product, but I want only update existing product by its id. Any one know ...
0
votes
2answers
130 views

Programmatically create a custom product in Magento 2

I have created a custom product. i.e <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Catalog:etc/product_types.xsd"&...
0
votes
2answers
722 views

Magento 2 - create order programmatically with flat rate - No shipping information available

I tried to create order programmatically with flat rate shipping method with the help of below code. Here, order created successfully but shipping method and rates not apply to order. use Magento\...
0
votes
0answers
99 views

How to remove duplicate product images programmatically magento2

How to remove the product's duplicate images programmatically.
0
votes
2answers
423 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
103 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 ...

1
2 3 4 5
8