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

Magento 2 Currency Setup - Allowed Currencies programmatically

How to set 'Allowed Currencies' for each store programmatically in Magento2. Options in Admin Panel are placed here: System -> Configuration -> General -> Currency Setup Also I'm not sure ...
1
vote
2answers
2k views

how to advanced search a products programatically

I need to search a products using advanced search with custom attributes programmatically. My advanced search works fine, i need to search product programmatically with our custom attributes. I ...
4
votes
5answers
14k views

Magento 2 - Create product programmatically with different store view values

I have created this custom import module that will create products and set different values for each store view. The problem is, when I save a single attribute for the product on a store view, all the ...
1
vote
3answers
14k views

How to correctly update product programmatically - Magento 2

The Context: By decision of the client, the Magento Administrator cannot add products by himself, all he can do is edit them, therefore the addition of products must be done programmatically. There ...
2
votes
0answers
874 views

Programmatically Create configurable product in Magento 2.1 Issue

I facing issue while creating configurable product in Magento 2.1 programmatically. I'm reading products from xml and save. The issue is when i associate simple product with configurable product. ...
2
votes
0answers
1k views

Add image to product programatically not using addImageToMediaGallery

Method addImageToMediaGallery() seems to me buggy, when using productRepository to save product, what encourage us to use deprecate method save() directly from product model (what causes other bugs), ...
0
votes
1answer
604 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'...
2
votes
1answer
2k views

Magento : Call widget call from phtml file

I have created Widget and want to call it from header.phtml In this widget i have called Static block but widget not called.This widget have id 2 i have set code below please help me to correct this ...
2
votes
1answer
785 views

Adding bundle product programatically

Using Magento 2.1.1. I have to add some bundle products programatically. Any post on stack doesn't work for me. Here is my code - it adds bundle products with some options and every option should has ...
2
votes
1answer
143 views

html / code not working in static block to add price in a specific block?

I've tried multiple snippets of code to add an item price to a specific block without success. On the example item page : https://fixlcdscreens.com/default/catalog/product/view/id/10234/s/...
2
votes
0answers
636 views

admin login programmatically in controller not working

I am using below code to admin login programmatically in magento root folder file name rootfolder/adminlogin.php Mage::getSingleton('core/session', array('name' => 'adminhtml')); // supply ...
1
vote
0answers
214 views

Magento 1 Random review generator

I have a site running Magento 1.9.3 and I want to generate random reviews. I don't need the content to be using target keywords or anything - I only need it for testing different layouts and design ...
8
votes
2answers
2k views

How to get disabled products in Magento 2

Is there a way to get disabled products programmatically in Magento 2 ?
4
votes
5answers
4k views

How to add bundle product to cart programmatically with custom price and quantity (of all products) in Magento 2?

I am struggling with Bundle Product add to cart programmatically in Magento 2. Here I need to add all products with custom price and quantity and I want to do this operation in Product list.phtml ...
0
votes
1answer
1k views

How can place the discount amount during order process programmatically?

For more details:- I am facing the same issue as this given below link. https://magento.stackexchange.com/questions/99767/creating-an-order-in-magento-with-fixed-discount-amount-via-models My ...
0
votes
0answers
218 views

magento programatically order create

I am trying to create order programmatically, but i am not able to create order. the below script is not working Mage::log($quote, null, 'quote.log', true); $service = Mage::getModel('sales/...
2
votes
0answers
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 \...
1
vote
3answers
2k views

Change Index Mode programmatically

i am looking for a way to change the mode of Magento 2 Indexer. The way it was done in Mage 1 : $pCollection = Mage::getSingleton('index/indexer')->getProcessesCollection(); foreach ($...
4
votes
3answers
9k 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
336 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
247 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
82 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
3k 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 ...
5
votes
4answers
4k 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
17k 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
488 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
377 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 ...
2
votes
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
1k 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
826 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
835 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
224 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
4k 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
3k 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
145 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
12k 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
22 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
957 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
1k 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
79 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
60 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
5k 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?

1
4
5
6 7 8