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
1
vote
0answers
5 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 '...
0
votes
2answers
84 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 ...
1
vote
1answer
24 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.
1
vote
2answers
18 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
774 views

How to add product reviews progmatically to add data on custom field

$review = Mage::getModel('review/review') ->setEntityPkValue(intval($pressquote->product_id)) //product id ->setStatusId(intval($pressquote->status)) ->setDetail($pressquote->text) -&...
0
votes
0answers
89 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
23 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 ...
2
votes
3answers
1k views

Magento2: How to temporarily disable “update on save” when saving products programatically?

I have a CLI command on my module that runs through the products collection & updates some of the attributes. I noticed that it's extremely slow. Each save() takes about 4-5 seconds, which is a ...
2
votes
2answers
1k views

Magento 2 : Add product to cart programmatically does not populate quote item id in validate method

How to add product to cart programmatically in Magento 2.2.0 ? I have tried below code but when I do not get Quote item id in Validate method of below file. \Magento\AdvancedSalesRule\Model\Rule\...
0
votes
0answers
45 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
13 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\...
2
votes
1answer
2k views

Magento2 - Add Custom Column in cart item table and insert data to custom column when product add to cart

i have added new column in 'quote_item' table. i want to add the data to custom column when user add any product to cart.
0
votes
0answers
22 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 ...
1
vote
1answer
1k views

Magento:Save Product image from external url

I want to save a simple product programatically.I have used the following link http://inchoo.net/magento/programming-magento/programatically-manually-creating-simple-magento-product/ All fields are ...
6
votes
4answers
5k views

Create a bundle product programmatically - Magento 2

I am trying to create a bundle product with Magento 2. But somehow its not linking simple products with the bundle product (i.e. its not saving bundle options & data, also linking same with ...
5
votes
5answers
11k views

Magento 2 Programatically add product to cart with additional options

I want to add product to cart with some additional data. My code adds the product to cart,but the additional info is not saved properly. I want to display the additional content in cart like custom ...
5
votes
4answers
4k views

set related/upsell products programatically only works for 1 product

I am trying to update products programatically and I'm having issues with the related/upsell section. It updates only with the last product sku. So if I am trying to link 3 products with a parent ...
2
votes
2answers
418 views

Magento2: Add pricing logic layer at the end

Before moving to Magento, I had a princing logic inside a table that involved (customer, customer group, item, item group, etc) There are some native features that I will take advantage of such as ...
1
vote
1answer
1k views

How to create Configurable Product Programmatically

I have found some question same my own but have not found out the answer. I want to create a configurable product. I have create a form to save the product and get the child product details in ...
3
votes
1answer
62 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 \...
1
vote
1answer
921 views

Can't Create Configurable Products with multiple Attributes programmatically

I'm trying to create a configure product with multiple attributes. Here is my code. Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID); $simpleProduct = Mage::getModel('catalog/...
4
votes
5answers
6k views

Magento 2 : How to clear mini cart programatically

I am using this solution and get referenece from Here. But It dose not update mincart after page refresh. Although it deletes items from quote_item table. I am also trying deleting quote id from ...
0
votes
0answers
12 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
69 views

$product->save() taking 4 seconds to save one simple product in magento 2.1.3

I have below code with Image Upload which is working fine...but it takes 4 seconds to save one simple product....my store have more than 25000 products. It takes more than 4/5 hrs to create/update the ...
4
votes
1answer
2k views

Create order programmatically for the items on cart on checkout page

I am successfully creating the order in the Magento dashboard with the below code. //for order $id=3; // get Customer Id $customer = Mage::getModel('customer/customer')->load($id); $transaction = ...
0
votes
2answers
1k views

Programmatically create new orders from multiple existing orders

I would like to programmatically create new orders from existing orders by their id and send new order confirmations by mail. The new orders need to contain all the information the old ones had (Items,...
2
votes
2answers
10k views

Magento2 programmatically adding a custom option

I'm trying to programmatically add a custom option to a product, there are no errors being returned, but the custom option doesn't get added. I've tried a few methods to achieve this, without much ...
0
votes
1answer
814 views

How Importing Images with Labels using addImageToMediaGallery in magento2?

Magento2.1.x I had a problem adding a product Image Label programatically. Here's the code I used: $imageLabel1 = 'Test1'; $imageLabel2 = 'Test2'; $imageLabel3 = 'Test3'; $product-&...
0
votes
1answer
41 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 ?
4
votes
1answer
3k views

Magento 2 check which catalog rule is applied to cart product

I have created 3 catalog rules for category. Shoes Category: 5% Off , Catalog Rule Name: Shoes Offer Toys Category: 10% Off, Catalog Rule Name: Toys Offer Fashion Accessories: 8% Off, Catalog ...
1
vote
0answers
18 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 ...
2
votes
1answer
730 views

Programmatically rename product images--existing images already uploaded--for SEO

I would like to create a simple script to programmatically rename existing, already uploaded product images (without having to re-upload them or use the admin backend). To process this in manageable ...
0
votes
0answers
110 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
3answers
1k views

Magento 2 store-view progmatically

In Magento 1 i used something like this to create 2000 store views on the fly. How would I do the same thing in Magento 2? require_once('app/Mage.php'); umask(0); Mage::app('admin'); $strnm =1; ...
1
vote
2answers
56 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/...
2
votes
3answers
2k views
0
votes
0answers
33 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
18 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
3answers
1k views

Error while trying to programatically create flat category

Using Magento 1.9.0.1 I am trying to programmatically create categories using a data upgrade script with the flat categories option turned on. This first category I want to create is a new root ...
6
votes
4answers
8k views

Magento 2: How to add customer address programmatically?

I have succeed create customer programmatically. Now I want to add customer address to the customer, how can i do this programmatically?
1
vote
3answers
4k views

Magento2: How can update & create the CMS static Page programmatically

How can update an existing CMS static Page and how to create a new CMS static Page - programmatically
0
votes
1answer
29 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
40 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-&...
2
votes
1answer
765 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
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
67 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
49 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
1answer
35 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
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(...

1
2 3 4 5
8