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.

Filter by
Sorted by
Tagged with
4
votes
3answers
8k views

Magento 2 how to add product attribute of type textarea with editor programmatically

How can we add custom attribute using setup script in magento 2 attribute type should be textarea with editor. Like Product description.
0
votes
2answers
291 views

Programmatically added product has empty Quantity field and doesn't show up on the frontend [duplicate]

I am trying to add a product to my Magento store programmatically. Basically I'm duplicating a template and editing it: $storeId = Mage::app()->getStore()->getId(); // get store id $product = ...
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 ...
3
votes
1answer
2k views

Catch errors from validation when saving product or category ($product->validate() or $category->validate())

I would like to validate the data before saving a product programatically because ->save() saves a product even if it doesn't have an sku. If I do ->validate() I get the expected error: [...
0
votes
1answer
48 views

I want to move all my products and their attributes to my new store

What is the best way to accomplish this? Please don't just say "magmi". Additionally, my dataflow profiles do not work on my local/vagrant build. It just keeps timing out. Is there a way to do it ...
4
votes
3answers
3k views

set related/upsell products programatically only works for 1 product

I am trying to update products programatically and I'm having issues with the related/upsell section. It updates only with the last product sku. So if I am trying to link 3 products with a parent ...
3
votes
1answer
14k views

magento 2 create categories programmatically [duplicate]

I would like to create categories programmatically in magento 2. Please suggest me proper code for it. I have try this code Link but not working properly . I have to create number of categories on ...
0
votes
1answer
456 views

Copy Product from website to website programmatically

In the admin you can do this: which is pretty easy to copy a product from one website to another, with the values of another website. Is there a way to do this programmatically? EDIT: I've ...
1
vote
1answer
357 views

Unable to create product programmatically

I'm trying to create a simple product programmatically in Magento CE 2.1 but I get this error : Exception #0 (Magento\Framework\Exception\CouldNotSaveException): Unable to save product The product ...
1
vote
2answers
2k views

Magento 2 - Set simple product Color when creating product programmatically

Can any one help me? When I create simple product in GUI I can set color value by dropdown menu. My question is: How to assign color value programmatically, when I create simple product? I have ...
0
votes
2answers
934 views

$product->getOptions() behavior inconsistent

If I run code to load a product and its options in a product view template file app/design/frontend/mymodule/default/template/catalog/product/view.phtml $product = Mage::getModel("catalog/product")-&...
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
1answer
803 views

How to add a selection for an option in bundle items in Magento

I have already created Bundle product in magento 1.9.2.2. All the bundle items are of "Radio Buttons" input type having few options already defined to them. This I have created using admin-panel. ...
0
votes
1answer
222 views

I want to add a product to cart programatically to cart when a product has custom option

I want to add a custom product(eg :cooler) to cart programmatically to cart when a product has custom option(as ice packing) or the cart items have custom option(as ice packing) and update the ...
2
votes
2answers
2k views

Magento 2 Product import to store id 0

I'm really struggling getting a simple product import to work on Magento 2. I've done this several times in ver 1.x without trouble, but M2 is driving me crazy The code should be simple $...
3
votes
2answers
3k views

How to search product programatically in magento 2?

I want to search product in custom page so how search products programmatically in custom controller ? Below Magento 1.x search programmatically $queryText = Mage::helper('catalogSearch')->...
0
votes
1answer
2k views

Set multiple multiselect values for product

I am working on a magento extension that automatically creates products from an import file. Everything is going great, except for one small issue i can't seem to figure out. I have created a few ...
1
vote
2answers
144 views

unset an item in an array based on conditional IF statement

I have an array that gets imported daily. For the specific field 'special_price' i only want it to import into Main Website > Main Website Store > Default Store View Default store view = 1 ...
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
1answer
21 views

Products in Magento DB but not Magento Admin

I created a script that imports simple products programatically. However, it appears 49 products are stuck in "limbo." They appear in the DB table "catalog_product_entity" but not within Magento's ...
2
votes
2answers
4k views

Programatically Create Order in Magento 2.1

Has anyone figured out how to programatically create an order in Magento 2.1 yet ? There are a few tutorials kicking around for 2.0 which work nicely but every since I upgraded it no longer works. ...
3
votes
3answers
2k views

Increasing all product prices by percentage | Custom Script

I am trying to find a way to update all product prices by 5% then I want to revert them to the original price and wondered if anyone had any ideas of the best way to achieve this. At the moment I am ...
3
votes
1answer
5k views

Update Custom Attribute Value Programatically

I have created a script that tests importing products programmatically into Magento. Unfortunately, I'm having trouble updating a product's custom attribute value - in this case "manufacturer." When I ...
1
vote
1answer
871 views

How to correctly create a configurable product with multiple attributes and images

I'm trying to create some configurable products programmatically, but I think I'm missing a step somewhere. I'm basing my code mostly off of inchoo's tutorial, but also off of about 2 dozen other ...
0
votes
1answer
999 views

Programatically creating shopping cart price rules

I have written a script to parse xml files to create magento shopping cart rules. With one of the rule types I am getting the following error: SQLSTATE[23000]: Integrity constraint violation: 1062 ...
0
votes
0answers
1k views

programmatically adding product to cart returns every time diffrent quote id in android application

Below code work perfect on IOS application but now work in android application. <?php error_reporting(0); include("../app/Mage.php"); umask(0); Mage::app(); $store_id=$_POST["store_id"]; $...
0
votes
1answer
72 views

How to Initiate a callout to an eternal system on an event happening in Magento2

I have a magento2 installed. I would like to know where and what changes do we make to initiate a callout from Magento to the external service with the event details. e.g Suppose a Product is sold. ...
4
votes
2answers
5k views

How to create store view or store programmatically and do it right in Mage 2?

I want to create store or store view programmatically and I use the followng code (for store view): $storeView = $objectManager->create(\Magento\Store\Model\Store::class); // Store - is a ...
0
votes
1answer
58 views

Shipment create not working programmatically

I am using below code to create shipment programmatically. $shipment = Mage::getModel('sales/service_order', $order)->prepareShipment($qty); $shipment->register(); $shipment->sendEmail(true)-...
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; ...
3
votes
1answer
4k views

How to add programmatically product to wishlist in Magento 2?

I want to add the product to the wishlist in magento2. What is the way to programmatically add the product into wishlist in Magento2?
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 ...
0
votes
1answer
55 views

Add product to quote skips product randomly

I need to create an order with more than 60 products programmatically but it seems like Magento skips some(around 3 or 4) products randomly. I think it's a problem with itemsCollection of _quote but I ...
0
votes
2answers
2k views

Send automatic mail after completed order

I would like to send my customers a mail, after a week, when the order has been completed. Can someone help me? (Magento 1.9.2). I also found a topic about this issue, but it is not updated for a ...
1
vote
1answer
4k views

Magento2 Getting cart content programatically outside of magento itself [duplicate]

I'm working on several cart displays and to do this i usually (in magento 1) make a small script outside of Magento load up the magento app and fetch a collection with the data. In magento2 this ...
0
votes
1answer
396 views

Add Order Programmatically

Hi i want add order Programmatically using magento 2 So i need A custom REST API something like /V1/order/add/:sku/:item_id/:qty/:user_id
1
vote
1answer
235 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
1answer
684 views

Creating new Magento products leaves 'Use default value' unchecked

I am creating configurable and simple products programmatically using the code $websiteid = (int) Mage::app()->getStore()->getWebsiteID(); $storeid = (int) Mage::app()->...
5
votes
3answers
4k views

Create a bundle product programmatically - Magento 2

I am trying to create a bundle product with Magento 2. But somehow its not linking simple products with the bundle product (i.e. its not saving bundle options & data, also linking same with ...
0
votes
1answer
175 views

Magento 2 get contact form

In Magento 1. I have the following code: $form = $this->getLayout()->createBlock("core/template")->setTemplate("contacts/form.phtml")->toHtml(); Need Help something similar for Magento ...
6
votes
2answers
6k views

Magento 2 - Change customer password programmatically

I have build a plugin on the authenticate() method in Magento\Customer\Model\AccountManagement with beforeAuthenticate(). It is working and I can change the firstname of something else of the ...
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....
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',...
0
votes
1answer
218 views

Loop script for invoice creation

Recently I have migrated our website. I have imported the orders however they all by default were changed to complete and no invoice was created. The main problem is that it works great with one ...
22
votes
4answers
32k views

Programmatically create a simple product in magento 2

I'd like to create simple product programmatically in magento 2. Is there any way to create ?
0
votes
1answer
213 views

Order assign to perivous order's customer

I am creating 2 orders from admin session programmatically..Both these orders are of different customers.When I am execute script that time 2nd order is assigning to 1st order’s customer. Address,...
0
votes
1answer
481 views

Magento reorder with existing order price

I have a requirement where an order needs to be created from an existing order i.e Re-order feature of magento but programatically. A cron job dispatches a reorder event based on certain conditions. ...
0
votes
1answer
806 views

Magento Product Custom option value setPrice not working programmatically

I just don't get it. I have installed Magento 1.9.2.2 CE in my site. But when I run following code as custom script from root directory, it doesn't set product custom option value price to my desired ...
2
votes
1answer
2k views

Delete url rewrite programmatically

I need to set some url rewrites for different pages. But when I started my CLI script, I had some issue "Request Path for Specified Store already exists." That's why I need to delete this url rewrite ...