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
2answers
22 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
2answers
39 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
1answer
20 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
1answer
26 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
0answers
20 views

Magento 2: How to get Get recently viewed product collection by customer id?

I'm trying to fetch all the products by customer-id for the recently viewed items, but the database table 'report_viewed_product_index' is empty but the recently viewed product is visible on the ...
0
votes
1answer
23 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 ...
0
votes
0answers
16 views

Old categories are not removed from product when using setCategoryIds

I am updating product details programmatically. I want to replace category IDs in product. But using setCategoryIds , it only appends new category IDs in product but not removing old categories. How i ...
0
votes
2answers
23 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
0answers
35 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 ...
1
vote
1answer
70 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-...
0
votes
1answer
26 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\...
0
votes
1answer
60 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
1answer
38 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
0answers
23 views

How can I reverse create Quote for Order in Magento 2?

I want to validate some data in the quote using rule conditions, but the quote gets delete after a period of time. How can I reverse create Order -> Quote programmatically?
0
votes
0answers
39 views

Magento 2 - Change order shipping method

In Magento 2, I try to change the shipping method for orders programmatically. I did this $order->setShippingMethod('my_new_method'); $order->save(); The shipping_method attribute is changing ...
0
votes
3answers
498 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 ...
0
votes
0answers
115 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\...
0
votes
0answers
105 views

How to add cms static block to category description programmatically

Instead of directly add cms block to category description, how to add programmatically?
0
votes
0answers
92 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
1answer
40 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
1answer
51 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
1answer
104 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 ...
0
votes
1answer
138 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
1answer
359 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
4answers
912 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
2answers
335 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 ...
1
vote
0answers
12 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
2answers
98 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
412 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
152 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 ...
0
votes
1answer
74 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
1answer
20 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\...
0
votes
0answers
59 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
0answers
134 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
227 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 ?
1
vote
0answers
20 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
2answers
115 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
0answers
162 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
578 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
47 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
230 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-&...
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
1answer
236 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
vote
1answer
325 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
47 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
vote
0answers
34 views

Magento 2.3: Order Create Programatically Script Allowed memory exhausted

I am working on creating orders dynamically using custom magento script , got reference from How to create order programmatically in Magento 2? now when I run script, after making 10-15 orders, first ...
1
vote
3answers
2k views

How to pass the value and call js function from template.html using knockout js in(in checkout page) Magento 2?

I have to call and pass value to the js function(showPopup())from the template(when clicking the Verify OTP button). How to achieve this?. But now i am not able to call the js function. layout file &...
1
vote
0answers
47 views

Custom Shipping Method as fallback

I've created a shipping method in magento2 . It checks if there is any oversize product in cart and if the package weight is more than 31.5 kg. How can I set this shipping method as default if ...
0
votes
0answers
22 views

Magento 2 Addtocart Group product programatically

I am facing the problem with the Addtocart group product. Can anyone suggest me the code? I have tried as a simple product but it's not working as well try with below code but that did not work out ...
1
vote
3answers
408 views

How Reindex and Reset programmatically in magento 2?

I Need to reindex and reset the indexer programmatically using external script from magento root. How can i achieve this.Is there a Way to do this.? I am new in magento. Please help me. Thanks in ...

1
2 3 4 5
8