Podcast #128: We chat with Kent C Dodds about why he loves React and discuss what life was like in the dark days before Git. Listen now.

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
339 views

Create virtual product programmatically

I'm using magento v2.5.5 to develop an extension, in this extension i have to generate virtual product with non manageble stock (infinite stock), how to do this programmatically, my virtual product ...
1
vote
0answers
257 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 ...
0
votes
0answers
64 views

magento 2.2.4 : Create orders programmaticaly

I want to know how to create orders programmatically. I want to create an order in the same time, add cart product when I click on by "confirm my order". I want my customer to add product to his ...
0
votes
0answers
42 views

Create orders programmatically 2.2.4

I want to know how to create orders programmatically without passing through the payment step. I know it's possible, using helper (or model, but I can't find the link): https://webkul.com/blog/...
2
votes
3answers
767 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
1answer
433 views

Product custom option delete while edit product programmatically

I have added a custom option in product from the back-end. After that when I tried to update the product programmatically but Facing an issue: When I edited the product all the custom options of ...
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
0
votes
2answers
4k views

How to create directory and text file and write content in file in media folder programmatically in Magento 2?

I tried to create directory and file and then put content in file programmatically but it does not work. Here is my code in sample.phtml <?php $om = \Magento\Framework\App\ObjectManager::...
2
votes
3answers
2k views

Get recently viewed products programmatically in Magento 2.2.2

I am trying to fetch recently viewed products. I tried to implement the provided code from here but did not get any success.
0
votes
1answer
1k views

Updating “Include In Menu” on categories programmatically in Magento 2 and not updating in the admin

I have the following code to get all categories which are active but not included in the menu. It then loops around these and updates them to be included in the menu. The script works on the frontend ...
0
votes
1answer
180 views

Magento 2 - Cant update categories programmatically Flat::validate()

Please could someone advise why I am getting this error when calling my code below: Uncaught Error: Call to undefined method Magento\Catalog\Model\ResourceModel\Category\Flat::validate() namespace ...
0
votes
1answer
194 views

Magento 2 Programatically create a product on the checkout_cart_product_add_after event

I'm currently working on a module that adds specific products to the cart when the customer adds a normal product. I created an observer for the checkout_cart_product_add_after. The user will select a ...
0
votes
0answers
196 views

Force change State/Status to Complete

Is possible to change the state of the order to complete? $order->setSate(Mage_Sales_Model_Order::STATE_COMPLETE); $order->save(); Programmatically : setState(Mage_Sales_Model_Order::...
1
vote
0answers
312 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 ...
0
votes
1answer
192 views

Creating Order Programatically Showing Wrong Grand Total

I've successfully created an order programmatically using custom prices for items. When I view the order, the item is correct, the subtotal is correct, but the Grand Total is double. Here is my code.....
0
votes
1answer
214 views

Custom image attribute not saving programmatically in Magento2

I have created a custom image type attribute. And trying to set image from code. But it is showing random behaviour. $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); ...
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
1answer
238 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 ...
0
votes
2answers
376 views

update products price with code

i want to increase my products price in magento foreach ($prodCollection as $product) { echo $product->getName() .'<br>'; echo "old: " . $product->getPrice() .'<br>'; $...
0
votes
1answer
77 views

How to create the order programatically in magento2

How to create the order programmatically in magento2 using objectManager. I need to test the order creating or not in the root folder. Can you please anyone help me.
0
votes
1answer
642 views

How can I add bulk attribute to attribute sets in Magento 2 programmatically

Everyone, How can I set attributes to attribute set in Magento 2 programmatically
0
votes
1answer
349 views

Magento 2 - How to assign custom theme to specific store programatically

Hi I have created 3 to 4 stores programatically Now i want to assign my custom theme to specific store using programatically. I have store id of each store which i have created. Below code i have ...
0
votes
1answer
104 views

How to resize existing product images backend?

I am Using third-party extension to Import product images https://www.magebees.com/magento-import-export-simple-products-configurable-products-bundle-products-group-products-downloadable-products.html ...
2
votes
2answers
951 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\...
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 ...
0
votes
0answers
640 views

Setting the Store View programmatically in Magento 2

I need to have the functionality where if a customer has a VAT number added to their account then I need to change them to a trade store view. I have the following code however the store view doesn't ...
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 ...
1
vote
1answer
281 views

Why magento 2 redirection from onepage not working?

My code in onepage.phtml for redirecting automatically for payment page when a specific product is added to cart. <?php $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $...
1
vote
1answer
24 views

Why this error Occurs?

I added a product programmatically in cart and redirected to checkout page. But Can't place Order. class Wallet extends \Magento\Framework\App\Action\Action { protected $formKey; protected $cart;...
1
vote
1answer
99 views

How to add products into cart programatically once after an checkout_cart_product_add_after is triggered? in Magento 2.2.x

<?php namespace Commerceshop\Vendor\Model; use Magento\Framework\Event\ObserverInterface; use Psr\Log\LoggerInterface as Logger; class Observer implements ObserverInterface { ...
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 ...
0
votes
0answers
67 views

How to checkout product programatically? [duplicate]

I need to checkout a product when a user comes to a specific block with a specified transfer method. I hope will get help.
1
vote
1answer
41 views

How to get from orders how many of selected product was sold - programatically?

Trying to get number of sold product from orders within range of time. How can I do it ... easiest possible method ? I can get a whole collection of orders from selected range of time, then get all ...
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 ...
0
votes
1answer
232 views

Change by Observer Product Weight

Im changing by checkout_cart_product_add_after the product Price and also want to change the Product weight. here is the code: Magento 1.9.3 public function checkoutCartProductAddAfter(...
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 ...
0
votes
0answers
339 views

Fast way to resave all products

I need a fast way to resave all 75.000 products in my Magento 1.9 store. Currently I use the following code, but that is not very fast. Is there a better and faster way to resave all products? CODE: ...
3
votes
2answers
2k views

How to disable/enable a product for admin store programatically in Magento2?

I want to disable product for admin store means product should be disable for all store/website. I am trying to do something like this but product disable for default store only: $productRepository =...
0
votes
1answer
916 views

Configurable Product Programmatically Configurations is empty

I am trying to import products from a .csv file and am almost there but I have an issue with the catalog_product_super_link Simple Products Created correctly with correct attribute values ...
0
votes
0answers
33 views

Where is the “Add product” tab in Magento 2 [duplicate]

Trying to add product manually for an existing customer, but the orange tab is no longer there.
0
votes
1answer
394 views

Add Category tree, if not exists programmatically

Ive been through several answers before succumbing to ask a question. I will list what i tried and why i think this is a bit of a special case, and not a duplicate. Am reading a .csv file from my ...
3
votes
1answer
507 views

How to create sortable array (draggable) in configuration

I would like to create an array in a custom module configuration where I can manually order the lines thanks to drag & drop. I can see there is a similar behavior in the related products when ...
1
vote
2answers
3k 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
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 ...
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 ...
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
1answer
1k views

Change Shipping Method Name programmatically

i want to change the Shipping Method Name programmatically in some cases. (This store is in german) So I want to change "Versand oder Abholung" to another different text depending on the case. How ...
0
votes
1answer
711 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-&...