We’re rewarding the question askers & reputations are being recalculated! Read more.

Questions tagged [programmatically]

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

122 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
6
votes
0answers
713 views

Override tax rate on programmatically created order

I'm building an extension which imports orders created on a third-party system into Magento. The third-party system should be the single source of truth for the order's prices, tax rate, tax paid, etc....
4
votes
0answers
82 views

Apply unique images by attribute to each sku magento 2 programmatically

In magento2 - How can I perform this task through a script? I already relate the configurations to the product with this segment $attributeModel = $this->objectManager->create('Magento\...
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 ...
4
votes
1answer
208 views

How add configurable product for selected options magento 2 programatically?

I want to add configurable product pragmatically. If product is ABC it has 3 size options XS M L so I want to add all options same time only changeable thing is quantity. I tried but it added as first ...
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 = ...
3
votes
0answers
28 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
1answer
116 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: <?...
2
votes
0answers
27 views

Optimized way to get Total Delivered Items in Magento 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 = ...
2
votes
2answers
206 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/...
2
votes
1answer
62 views

Magento programmatically refresh statistics. - Magento1

How to refresh statistics programmatically in Magento 1?
2
votes
2answers
946 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\...
2
votes
0answers
131 views

Magento 2 - Choose payment method for one checkout programmatically

Question (+ TL;DR) Is it possible to choose programmatically specific payment method only for actual checkout process, like - one time choice? Some context: I'm developing a plugin for magento ...
2
votes
0answers
159 views

Magento2 : Add Simple Products to bundle product selection

I have a bundle product created from Admin Section. Now I am updating inventory of simple products i.e adding products to Magento Catalog Programmatically via CSV file. I want to add those simple ...
2
votes
0answers
245 views

Add product to cart programatically is not setting price when we add product at first time

When adding product first time to the cart is not setting the product price, But when we add another product to the same cart (second time) the price of both product is set. my code is below: public ...
2
votes
1answer
1k 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.
2
votes
1answer
566 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 ...
2
votes
0answers
848 views

Programmatically Create configurable product in Magento 2.1 Issue

I facing issue while creating configurable product in Magento 2.1 programmatically. I'm reading products from xml and save. The issue is when i associate simple product with configurable product. ...
2
votes
0answers
1k views

Add image to product programatically not using addImageToMediaGallery

Method addImageToMediaGallery() seems to me buggy, when using productRepository to save product, what encourage us to use deprecate method save() directly from product model (what causes other bugs), ...
2
votes
0answers
571 views

admin login programmatically in controller not working

I am using below code to admin login programmatically in magento root folder file name rootfolder/adminlogin.php Mage::getSingleton('core/session', array('name' => 'adminhtml')); // supply ...
2
votes
1answer
3k views

Magento2 - create new/update category programmatically for specific storeView not working

When I try to update a category category name programmatically only for StoreView 2, it does not work. The changes will go to StoreView 1 every time and not to the StoreView that I defined: use \...
2
votes
0answers
795 views

Programatically generate order with custom order#

I'm using the code available here to generate orders programmatically (importing from an older in-house system) and its actually working quite well. I've made some changes to check/create customers as ...
2
votes
0answers
264 views

Delete all orders and quotes of customers that do not exist anymore

On our testing environment we are constantly creating new customers and also (mass) removing them again, currently only having 12 customers. Now after a while our sales_flat_order (5038 rows) and ...
2
votes
3answers
755 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 ...
1
vote
0answers
17 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 ...
1
vote
0answers
56 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 .
1
vote
0answers
21 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
136 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
0answers
37 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 '$...
1
vote
0answers
80 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\...
1
vote
0answers
208 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 { ...
1
vote
0answers
309 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/...
1
vote
0answers
254 views

Duplicate quote on reload last quote

Recently, I needed to create an order programmaticaly. Here's my code : public function createMageOrder($orderData) { $store=$this->_storeManager->getStore(); $websiteId =...
1
vote
0answers
79 views

Update product stock with observer Magento 2

right now I need to have a sincronization between my magento products and a third party software, lets call it X, X stores all the products info, my goal is to use a observer to update a single ...
1
vote
0answers
306 views

Import products and customer data programatically

I needed to programatically export and import customer data, product data and order details. I've successfully created my exports. I'm having problems with my import. I need to do this using an ...
1
vote
1answer
236 views

How to load filter state for admin grid?

I'm looking for a way to get the state/settings for the order_sales_view grid on a in a php class. I want to load the grid and the filter state to use for selecting previous and next order according ...
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 ...
1
vote
0answers
123 views

Magento 2: Fetch products with layered navigation programatically

I want to get products with layered navigation. I found sample code for Magento 1 below. How it can be done in Magento 2 ? http://www.credevator.com/magento-fetch-products-with-layered-navigation-...
1
vote
0answers
143 views

How do I add a buy X get Y free product to cart programmatically with shopping cart rule?

I have a shopping cart rule, Buy product with SKU XXXXX and get Product with SKU YYYYY discounted. I want to automatically add Y product to cart when X product is added. What I've tried Creating an ...
1
vote
0answers
1k views

Get shipping price with and without taxes

I doing a connection with a webmarketplace. So I developed a script to export my products into a xml file. But, one of the problems I have is that I can't get the shipping amount. I need to get ...
1
vote
0answers
356 views

How to update product image based on product name using script. Magento 1.9.2

I want to update the image of one category shoes .In this category there are 10000 products , I want to update the image of those products only which have nike brand in their name , using script. ...
1
vote
0answers
54 views

Programmatically created product Urls are not generated for french storeview in Magento 2

I am trying to create a product programmatically in magento 2.1.3. I have 2 storeviews, be and fr. when I create product, product URLs(in URL rewrite) are only created for 'be' storeview, not created ...
1
vote
0answers
230 views

Category attribute not saving with RepoInterface

Im trying to update existing Categories. They have a Custom Design (Theme) because of the general theme we are using and I forgot to add that to the creation code. So I setup a simple script to ...
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 ...
1
vote
0answers
194 views

Magento 1 Random review generator

I have a site running Magento 1.9.3 and I want to generate random reviews. I don't need the content to be using target keywords or anything - I only need it for testing different layouts and design ...
1
vote
0answers
245 views

Adding product variations using the configurable product module

I have issues creating configurable product using the configurable product and EAV modules. Here is what I currently do : // $product is a simple product created before $product->...
1
vote
1answer
80 views

customer massive import

I am working on magento very custom. Now i have created a script for the import customers. This script does more checks. Now... into the database there are 1400 customers. My script import into ...
1
vote
0answers
730 views

Programmatically importing products are slow to save when adding images in Magento 2.1

I have a script which imports products from XML data POSTed to it from an external source into Magento 2.1. Everything works and imports fine, however when images are added to a product, the $product-...
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
1answer
234 views

Add an attribute TO A PRODUCT programmatically

After searching for examples using "magento add attribute to product programmatically" I keep getting copious results on adding or removing ATTRIBUTES programmatically. I want to programmatically add ...
1
vote
0answers
153 views

Problem when programatically changing configuration on Magento EE 1.13.1

I need to automatically change the value of 2 keys stored on Magento configuration. After some research I've reached the following snippet: $config = Mage::getConfig(); $config->saveConfig('path1',...