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
2
votes
1answer
11k views

Magento 2 programatically add product to cart? [duplicate]

We have a requirement that we wants to add product to cart programmatically in magento2.
1
vote
1answer
656 views

Programmatically adding product to cart returns empty cart

I'm trying to add a product to cart programmatically in magento 1.9.3.3. The code adds database entries (created rows in sales_flat_quote_item and sales_flat_quote tables). But the cart shows as empty....
3
votes
2answers
940 views

Show customer data after setCustomerAsLoggedIn()

Im experiencing an issue with Magento 2.1.7 I want to login users programmatically by only their email. But after setCustomerAsLoggedIn it still shows sign in or create an account in the header. ...
1
vote
0answers
356 views

How to update product image based on product name using script. Magento 1.9.2

I want to update the image of one category shoes .In this category there are 10000 products , I want to update the image of those products only which have nike brand in their name , using script. ...
3
votes
3answers
5k views

Magento2 how to add configurable product to cart programmatically [duplicate]

Magento2 how to add the configurable product to cart programmatically. I searched but found question related to how add simple product mostly.
4
votes
1answer
2k views

Create order programmatically for the items on cart on checkout page

I am successfully creating the order in the Magento dashboard with the below code. //for order $id=3; // get Customer Id $customer = Mage::getModel('customer/customer')->load($id); $transaction = ...
1
vote
1answer
55 views

Can I Prevent Magento 2 from appending a number when uploading images?

We recently upgraded to Magento 2. On our M1 install, we used a script which did direct database insertion for our product images. This had the effect of allowing us to use one image for many ...
3
votes
1answer
666 views

Difference between catalog_product_prepare_save and catalog_product_save_before

What is the difference between catalog_product_prepare_save and catalog_product_save_before? I have an observer that updates some attributes when a product is saved. It works great when I save a ...
1
vote
0answers
54 views

Programmatically created product Urls are not generated for french storeview in Magento 2

I am trying to create a product programmatically in magento 2.1.3. I have 2 storeviews, be and fr. when I create product, product URLs(in URL rewrite) are only created for 'be' storeview, not created ...
2
votes
1answer
364 views

Magento2: Add pricing logic layer at the end

Before moving to Magento, I had a princing logic inside a table that involved (customer, customer group, item, item group, etc) There are some native features that I will take advantage of such as ...
0
votes
1answer
545 views

Magento 2: How to get product attributes?

How can I get the list of attributes that a product has? Foe example: Product "camiseta" has color and size as available attributes.
0
votes
2answers
65 views

One Image uploading instead of two for Programtically created Product

Once we click on button present in Product view page, we are doing 2 things : Creating 2 images in folder media/custom_product_preview/quote/ Creating new Product Programtically & uploading those ...
1
vote
2answers
353 views

Magento 2 : Error while adding product programatically On Observer Event `catalog_product_save_after`

I am trying to add product programmatically on catalog_product_save_after observer. Basically what i try to achieve is create a Duplicate Sample product of current product if PRODUCT-SKU-sample does ...
8
votes
4answers
4k views

Create an admin user programmatically in Magento 2.0

It is simple to add new admin user in Magento 1.9 <?php require_once('app/Mage.php'); umask(0); Mage::app(); $user = Mage::getModel('admin/user') ->setData(array( 'username' =>...
1
vote
1answer
388 views

How to change Stock Availability automatically to '0'

I want to change the stock availability to '0' automatically when product is OUT OF STOCK. I had created the Stock Availability attribute manually but when product is OUT OF STOCK the value of Stock ...
2
votes
1answer
1k views

Magento2 - Add Custom Column in cart item table and insert data to custom column when product add to cart

i have added new column in 'quote_item' table. i want to add the data to custom column when user add any product to cart.
0
votes
1answer
356 views

Multiple Inventory slots for Different warehouses

I have found a great script that allows for quick inventory updating via a php script, and it does work well. I am able to just go by SKU, quantity, and set each as is_in_stock. My question then ...
0
votes
0answers
155 views

magento 1.9 Create order programmatically in aed currency with aed rate

I want to create order in aed currency. In store, there is only 2 currency 1 is pkr which is base currency and other is aed. When I switch PKR to AED order place in pkr. <?php error_reporting(...
0
votes
5answers
2k views

How to delete an order programatically in Magento 2?

How can we delete a Magento2 order programatically? There's ways to do this in Magento 1.X. Is it the same methodology for Magento2 as well?
0
votes
1answer
588 views

Programatically add Item to Quote with Tax Information

I've been reviewing options for programmatically adding an item to a customer's quotation on the final stage of checkout (by selecting a tick box) which adds a simple product to the customer's order (...
0
votes
0answers
55 views

Creating a category programmatically using category factory, category data gets created in DB, but category is not visible in admin

Pretty much self-explanatory. I create a category model using category factory and then use the ->save method to save the category. I can see some data created, along with catalog_category_entity, ...
1
vote
1answer
520 views

Placing Guest Order Programatically

Hi I have a form posting information to a page which will then place an order as a guest with what is in the current sessions basket but I am having some issues. I get the error: Please check ...
0
votes
1answer
104 views

Generate dynamic page with magento 1.9. - 2.1

I have a php api to generate html code. What I'd like is to use it with magento. is posible to do it ? This is my target : run_magento() --> generate magento page By example in magento 2.1 we ...
4
votes
4answers
5k views

Magento 2 : How to clear mini cart programatically

I am using this solution and get referenece from Here. But It dose not update mincart after page refresh. Although it deletes items from quote_item table. I am also trying deleting quote id from ...
1
vote
2answers
426 views

Create Product Programatically with same Product name

We are displaying "Create product" link in product view page , once we click on link, we are creating product in backend. addtocart.phtml <button> <a href="<?php echo Mage::getUrl("...
4
votes
3answers
2k views

How to programmatically add custom options to all products without duplication?

I have over 40,000 products in store and am trying to add custom options to all. The script below works fine, but stops after about 1000 products, then starts again.. making duplicates rather than ...
1
vote
0answers
230 views

Category attribute not saving with RepoInterface

Im trying to update existing Categories. They have a Custom Design (Theme) because of the general theme we are using and I forgot to add that to the creation code. So I setup a simple script to ...
0
votes
2answers
1k views

magento 1.9 programmatically add / update record

What is the way to programmatically Update an existing record, and Add a new one if the record is not found in Magento 1.9? I have the following code, and what I want it to do is to add a new address ...
5
votes
2answers
4k views

How to retrieve custom attribute set ID by name

I have created couple of custom Attribute Set and now I want to assign a group in those attribute sets programmatically, so is there any way to retrieve attribute set IDs based on name?
1
vote
1answer
1k views

Magento:Save Product image from external url

I want to save a simple product programatically.I have used the following link http://inchoo.net/magento/programming-magento/programatically-manually-creating-simple-magento-product/ All fields are ...
2
votes
1answer
1k views

Can I change the taxes on a quote item in magento2 programmatically?

I need to change the tax rate on quote items in a magento2 checkout process that is entirely done programmatically. What I've found from various resources here on stackoverflow is that is possible to ...
2
votes
1answer
566 views

Programmatically rename product images--existing images already uploaded--for SEO

I would like to create a simple script to programmatically rename existing, already uploaded product images (without having to re-upload them or use the admin backend). To process this in manageable ...
0
votes
1answer
754 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
11k 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
11k 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
848 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
585 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
712 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
121 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
571 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
194 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 ...
7
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
3k 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
209 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
1answer
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 ($...