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
1answer
678 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 = '...
9
votes
10answers
19k views

Magento 2: Programmatically Updating Inventory

In the following code, I am able to store all the information with the exclusion of the stock data. Has something changed in Magento 2? public function __construct( ScopeConfigInterface $...
1
vote
1answer
725 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) -&...
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 ...
2
votes
3answers
739 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 ...
5
votes
4answers
8k 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 ...
2
votes
2answers
944 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
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.
1
vote
1answer
2k views

How to create order programmatically with customer email in magento 1.9

I want to place order with customer email id in magento 1.9 For this i need a script means i want to do it programmatically in php Please help asap
1
vote
1answer
158 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, ...
8
votes
2answers
13k views

Magento2 - How to add a product into cart programatically when checkout_cart_product_add_after is fired

Consider there are two product ie: Product A and Product B. Product B is a virual product which i need to add to cart when Product A is added to it. To do so, I am trying to add Product B to cart by ...
4
votes
0answers
80 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\...
2
votes
1answer
45 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
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 ...
0
votes
2answers
38 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 ...
0
votes
0answers
20 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 ...
1
vote
1answer
18 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
15 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 ...
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
1answer
918 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/...
2
votes
4answers
126 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 ...
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 = ...
0
votes
2answers
29 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
98 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
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,...
0
votes
0answers
36 views

How to remove duplicate product images programmatically magento2

How to remove the product's duplicate images programmatically.
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 \...
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
43 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
26 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
32 views

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

$product ->setPrice($price) ->setSpecialPrice($price) ->setTierPrice([]) ->...
0
votes
1answer
704 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-&...
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
2answers
843 views

How to create guest order programmatically for Guest User

I have followed Create order programmatically in Magento 2 But it is saving the customer. And When I skip customer set data and customer save then It's getting an error report like "Please enter ...
0
votes
0answers
80 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
1answer
585 views

'Not valid template file' error when printing invoice programatically

I'm trying to find a way to print an order's invoice programatically. For that I tried to get the url that Magento uses in backend to print an invoice but it didn't help as it uses a key that I couldn'...
0
votes
0answers
38 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
49 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
1answer
637 views
0
votes
1answer
95 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 ...
0
votes
0answers
23 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 ...
13
votes
3answers
10k views

How to add a CMS block programmatically in Magento 2?

I need to add a CMS block via an install/upgrade script. I've already figured out how to add "normal" CMS pages as seen in the script below. But since I can't find any way to add CMS blocks in Magento ...
1
vote
3answers
998 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
37 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
111 views

Magento 2 How to update block programmatically?

How can i update block content programmatically?
0
votes
2answers
41 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($...
1
vote
1answer
64 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/...
3
votes
3answers
150 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; $...
0
votes
1answer
31 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\...
3
votes
2answers
405 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->...