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

Update the configurable products without looping

I'm searching for a solution to update the configurable product's stock and price. Because all of the configurable products have more than 1000 variants, looping through all of the child SKUs and ...
0 votes
1 answer
48 views

Update price progrmmatically

I'm trying to update the price for configurable product programmatically. But the price is not updating. Also I'm getting integrity constrain error when the sku is not assigned. if($proType == '...
0 votes
1 answer
19 views

Can a widget extend a class besdides Template?

All widgets I have ever created programmatically extends Template implements BlockInterface and I was curious if you can extend different classes for a widget module's block?
1 vote
0 answers
28 views

Error in Shipment Email in magento 2 when creating programmatically

I created the shipment programmatically. Shipment is created and email is not sending. I am getting the following error. I followed RAKESH JESADIYA's this tutorial for this task. main.CRITICAL: Error:...
  • 2,651
4 votes
2 answers
4k views

How to update product salable quantity in Magento 2.4 programmatically?

I am trying to import products programmatically into a Magento 2.4.4 installation but I have problem setting the Salable Quantity. I cannot find a viable solution to this issue, please help if you can....
  • 43
1 vote
1 answer
64 views

Custom attribute created programmatically not working properly - Magento 1.9

I'm developing a module that creates configurable products, it's simple products and the attributes used to create this configurable (if not exists). All seems fine, products are created, associated ...
0 votes
2 answers
844 views

Magento 2 : How to calculate discount and shipping charges to programmatically created order?

I'm creating an order programmatically. I have added cart price rule in backend for subtotal above 1000 will get 30% product price discount on product When generating order(programmatically) as a ...
  • 1,915
1 vote
0 answers
221 views

Magento 2 $quote->getAllItems(); set StoreId or Website

Try to catch the quote items, it's working fine. But when quote is not in default website, the request is empty. How to change website ID or store ID in quote request? Did try with: $quote->...
0 votes
2 answers
295 views

Magento 2 How to create back order programmatically

I have created order programatically for my some of the store products and it's created successfully. but my some products are 0 qty than also i want to create order for that 0 qty products. can ...
1 vote
2 answers
177 views

How to Get Order Details in Magento 2?

Want to get the order details programmatically, need to use an object manager. But unfortunately, Magento 2 restricts the direct use of the ObjectManager.
0 votes
1 answer
28 views

How to check if tablerate is active in custom shipping method?

I have custom shipping method but I would like to return false when tablerates is appear in Checkout page. Anyway to check the condition?
0 votes
1 answer
129 views

How to Programatically cancel order in magento 2

If a customer placed an order of 3 different items with different quantities like shirt 2 qty Watch 1qty pant 3qty and cancels the order item at different times I have to set the state to order ...
0 votes
1 answer
108 views

Magento 2: How to add different watermark based on Vendor?

I have a multi-vendor setup on my site and based on per vendor products, I want to apply a watermark. By default, Magento applies watermarks on all the products based on the website/ store. Can anyone ...
  • 60
0 votes
2 answers
368 views

How to get all products with attribute data in custom created class

I'm pretty new to Magento, and I are trying to create a module for it, but I'm a little stock now because I'm trying to get all products out there are created in the store there are enabled. I'm ...
0 votes
0 answers
87 views

Magento 2: Set cron schedule dynamically from frontend

I want to set schedule of cron job from values chosen by the customer from the frontend. I have created checkboxes on checkout page through which I want to set the schedule of email reminders chosen ...
  • 330
1 vote
1 answer
512 views

How to refund only part of an order programmatically

I am looking for a way to programmatically refund part of an order within a custom module. I have been following this blog post (https://www.rakeshjesadiya.com/create-creditmemo-for-order-item-in-...
  • 176
0 votes
1 answer
333 views

How to apply cart rules directly on Order?

I have added a BIN promotion which is needed to be applied just before payment directly on order. I have found 2 methods that apply discount but require a quote object. \Magento\SalesRule\Model\...
  • 1,522
0 votes
1 answer
221 views

How to create ui-select in form programmatically

My code to generate the field multi-select $fieldset->addField('multiselect2', 'multiselect', array( 'label' => __('Select Type2'), 'class' => 'required-entry',...
0 votes
1 answer
938 views

magento 2: how to checked use default value for product status programmtically?

I have to update and checked checkbox for use default field for product status. But I do not know how to update and checked that checkbox ? here is my code $objectManager = \Magento\Framework\App\...
0 votes
3 answers
1k views

Magento 2 Place Order Programmatically Using Event Observer

Created a custom form where customer and product details filled with status of Active/Not active So for now I want to create an event and observer to place order programmatically when status is Active ...
  • 1,074
0 votes
0 answers
261 views

Magento 2 - Using observer how to Set CMS block to category description block programmatically

Using observer how to set catalog categories content Add CMS Block (category.description) programmatically My observer: <?php namespace Zero\DescBlock\Observer; use Magento\Framework\Event\...
  • 145
0 votes
0 answers
284 views

How to add cms static block to category description programmatically

Instead of directly add cms block to category description, how to add programmatically?
  • 145
0 votes
0 answers
288 views

Magento 2: Error while create category programmtically: Call to undefined method Magento\Catalog\Model\ResourceModel\Category\Flat::getEntityTable()

I am creating a category programmatically in magento 2 in controller, but I am getting error Call to undefined method Magento\Catalog\Model\ResourceModel\Category\Flat::getEntityTable() I have also ...
0 votes
1 answer
118 views

Set Product Custom Options From Observer Magento 1.9

I am trying to add custom options to products on save. I want to add or update custom options (not additional options) on before_product save. I am able to access the observer and it is working on ...
0 votes
1 answer
219 views

How to delete a product's category Magento2

I am trying to delete a product's category in magento 2 using the following code. public function deleteCategories($product_id){ $categoryIds = $this->productCategory->getCategoryIds($...
0 votes
1 answer
471 views

How to add field value while creating a simple product Programmatically in Magento 2?

I have successfully created simple product Programmatically using magento 2. But i have created a filed in back end and add that in product but how to fill that data when creating a product. I have ...
  • 586
0 votes
1 answer
284 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
1 answer
808 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
4 answers
1k 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
2 answers
737 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 ...
  • 133
1 vote
0 answers
16 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
2 answers
451 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 ...
  • 41
1 vote
1 answer
619 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
1 answer
490 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 ...
  • 586
0 votes
1 answer
151 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
1 answer
56 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\...
  • 15
0 votes
0 answers
95 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,461
1 vote
0 answers
253 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 ...
  • 11
0 votes
1 answer
807 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 ?
  • 145
1 vote
0 answers
21 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 ...
1 vote
3 answers
597 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
0 answers
320 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 ?
  • 1,417
0 votes
0 answers
976 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 ...
  • 1
0 votes
1 answer
120 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
1 answer
559 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-&...
  • 1,039
0 votes
1 answer
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, ...
  • 141
0 votes
1 answer
391 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.
  • 1,147
1 vote
1 answer
741 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($...
4 votes
1 answer
323 views

Magento 2 - Edit order programmatically without canceling

I want to edit any order programmatically. The tutorials that I am getting is canceling current order and creating new one. But I need something different, I want to edit it without canceling or ...
0 votes
0 answers
77 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
2 3 4 5
8