Questions tagged [product]

Denotes a question related to the Magento products.

Filter by
Sorted by
Tagged with
80
votes
6answers
68k views

Difference between getSize() and count() on collection

I have heard many times that they both are the same. But I am facing a weird issue, in the product collection of CatalogSearch module, count() is returning correct product count while getSize() is ...
40
votes
1answer
6k views

How to add a new product type in Magento 2? (MageStackDay mystery question 1)

MageStackDay bonus question for 500pts Bounty AND a the possibility of winning a free Z-Ray license for a year. More info can be found >> here << The questions are provided by Magento 2 core ...
37
votes
1answer
13k views

Product.OptionsPrice is not a constructor magento 1.9.3

I have upgrade magento 1.9.2.4 to 1.9.3. I am facing the following error in the console in product page. TypeError: Product.OptionsPrice is not a constructor var optionsPrice = new Product....
37
votes
1answer
26k views

Recurring Profiles - How do they work?

I'm trying to understand how Magento manages Recurring Profiles and orders associated with them. I have some open questions about that: Order: How the subsequent "order" is created from a Magento ...
33
votes
4answers
31k views

Get original image file from a cache URL

Is there any function that given a cache image product file return the original one? Example : => Cache URL: {BASEURL}/media/catalog/product/cache/2/image/9df78eab33525d08d6e5fb8d27136e95/a/l/IMAGE....
33
votes
8answers
14k views

Questions to expect in an interview for a Junior Magento Developer Position

Firstly I would like to say that I hope I am not posting in the wrong place with this question and if I am please advice me of where (if anywhere in the stackexchange world is appropriate) I should ...
27
votes
5answers
66k views

Why Can't I Load a Product by SKU using loadBySku()?

Synopsis I wanted to load a product by SKU there are many articles, blog posts, stack overflow results etc. All I want to know is - why does it have to be so difficult to load a product by a SKU? //...
27
votes
4answers
32k views

Efficient get product url from id

What is the most efficient way of getting a product url given just it's ID? In a few places in our code we have things such as Mage::getModel('catalog/product')->load($id)->getProductUrl() in ...
27
votes
4answers
41k views

Upgrade script - Create new select attribute with options

I would like to create a new product attribute with some predefined options using an upgrade script. I have an upgrade script working, so the only thing i dont know how to do is to add the drop down ...
25
votes
7answers
44k views

How to load product by SKU in magento 2

It's pretty basic, but I can’t find a working example on Stackexchange or google. I want to load a product from a helper or block. I already tried some things like: $objectManager = \Magento\...
23
votes
1answer
84k views

Magento2: How to load product by id [duplicate]

I got the product collection in my custom template using the following snippet: <?php $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); /** @var \Magento\Catalog\Model\...
23
votes
3answers
13k views

Faster way to load media images in a product collection

TL;DR: How do I load the product images/gallery without loading the whole product? I want to load the images on a product. What I do in the .phtml $_popularCollection = $this->...
22
votes
13answers
28k views

Getting full image URL of product in template

I'm trying to create a static block for showing dynamic products. This is code that is supposed to get every child category and print the image for each product in each category. <?php $...
22
votes
2answers
24k views

product attribute to quote item and order item

What is the correct way in Magento to have a product attribute be automatically persisted to quote an item and then finally to order item? Is it as simple as a little config XML or is it a manual ...
21
votes
4answers
30k 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 ?
19
votes
1answer
34k views

What is getBlockHtml('formkey')?

I am trying to edit the product edit page (first tab) in Magento and would like to move the quantity (as well as a few other things) from their respective tabs up to the first page. I see <form ...
18
votes
6answers
8k views

Magento 2 - How to retrieve product informations

I want to use functions like getName(), getPrice(), etc. of product to retrieve product information in Magento 2. Can anyone show me how can I achieve that ?
18
votes
6answers
7k views

How to allow only one product in a cart?

We have a requirement, wherein a customer will be allowed to add only one product to the cart at a time. However he/she can add any quantity of that product. How can I prevent a product from adding ...
18
votes
2answers
16k views

Magento 2: Product URL Suffix

How do I remove the .html suffix from the product pages?
17
votes
4answers
23k views

How can I fix “Item (Mage_Catalog_Model_Product) with the same id ”xxx“ already exist”?

I have been getting this error when trying to filter a products collection Item (Mage_Catalog_Model_Product) with the same id "6058" already exist and wanted to ask what could ne causing the error ...
16
votes
4answers
7k views

Bulk update products to include new websites

A client has 20000+ products with 7 websites. They used to have 4 websites and most products are associated to 4 websites. What is the best & quickest way to iterate through the products and ...
16
votes
2answers
15k views

How to Programmatically set a Product's Multi-Select Attribute by Labels

If have a multiselect attribute and want to set the selection on a product. $selectedOptions = "red,green,blue"; $product->..... // # what to do? How can I do that?
15
votes
2answers
8k views

Magento failing when trying to save product inside event observer on frontend?

I have a function that is tied to an event observer One of the requirements is that when it loops through the order item data, if a certain product attribute is empty it issues a request to get ...
15
votes
6answers
12k views

How to check if a product is new

From a quick search the only reference I found was on the Magento forums which is suggesting that you have to write some custom code to check if a product is new. I would have thought there would be ...
15
votes
2answers
10k views

Creating Custom option and prize to just added product to cart using observer

I want to add custom option to quoteitem using observer which observer checkoutCartProductAddAfter event and fires after product added to cart. public function checkoutCartProductAddAfter(...
15
votes
4answers
4k views

Adding multiple items with different attributes to cart programmatically

I'm making a bulk add to cart system. Please note : i want it to works for simple products with with custom options -> Where custom option are like color(red , green , blue) or Size(Xl, M , S) ...
15
votes
2answers
2k views

sorting cart items by 'updated_at'

This is how i'm getting the cart items: $quote = Mage::getModel('checkout/cart')->getQuote(); $items=$quote->getAllitems(); I'd like to do something like this: $items->sortBy('updated_at','...
15
votes
1answer
460 views

Magento2 Catalog Product Options

We found this issue when working in a default Magento2.1. While creating customizable options for a product, if I select the drop-down field a second time, the spinner never stop loading. Please ...
14
votes
4answers
20k views

Fastest way to update an attribute in all products

I'm trying to update the price to a lot of products (more than 10.000). The way I am doing that right now is extremely time-consuming. Which is the best way to loop through all the products and update ...
14
votes
4answers
25k views

How do I get the current product in Magento2?

I'm trying to retrieve the current product's attributes in a block in Magento 2. I can get a product, like id 1: $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $product = $...
14
votes
3answers
21k views

How to list all disabled products with sql?

I need to list all disabled products by using a MySQL query. I have too many products in my database to be using something like this (creating a collection, loading it and looping over it): http://...
14
votes
7answers
16k views

Invalid Form Key. Please refresh the page. error on product save

Hello AllI am getting this error "Invalid Form Key. Please refresh the page." whenever I try to save my product on admin panel. I have gone through this link here but no success. When I looked at my ...
14
votes
4answers
6k views

Exclude certain products from Magento sitemap.xml generation

I need to make sure a handful of products are NOT in the generated Sitemap.xml file in Magento. I found a couple of example for things like CMS Pages but nothing for doing product pages, and more then ...
14
votes
1answer
5k views

Automatic 301 redirects for disabled products

I'm trying to add automatic redirects for a custom Product Type (Event) in Magento 1.7. When an event date has passed, I am marking the product as disabled so users don't go to the wrong page, and I ...
14
votes
3answers
13k views

Magento 2 : get rewrite product url

I am trying to get rewrite product url from the load product in custom module. I am getting url in http://localhost/m2/catalog/product/view/id/1401/category/23/ format . But I want http://localhost/...
14
votes
1answer
611 views

Magento 2.1 Ui Component form field Token input

I want to add tags in an input field , in a similar fashion as it is done in product form to add catageories - which is show in the image below. This much task I have achieved by adding field ...
13
votes
6answers
38k views

Magento 2 - How to get attribute of product?

How to get attribute of product?
13
votes
3answers
9k views

Read-Only Product Backend attribute

I would like to create an attribute read only however it look it is not possible. I have tried to pass to addAttribute() 'disabled' =>true or 'readonly' => true with out any success. I have ...
12
votes
2answers
18k views

How to save value for a Specific[custom] Product Attribute from Product Model

How to save value for a Specific[custom] Product Attribute from Product Model ? I have found the below script from here : $product = Mage::getModel('catalog/product')->load(1); $product->...
12
votes
2answers
41k views

Magento 2 : Get Custom Attribute Value of Product [duplicate]

I'm trying to get custom attribut from my product. I tried various methods like below, but non of them worked. $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); /** @...
11
votes
7answers
13k views

New Product: “Asymmetric transaction rollback.” error

When creating a new product and trying to save it, I get the following error message: Asymmetric transaction rollback error Has anyone else encountered this? Please share the fix :)
11
votes
3answers
46k views

Get Option Value by Id of Attribute in Magento

How can Magento find an attribute value by a given attribute label or a given attribute id?
11
votes
4answers
11k views

How to get a list of all products in Magento 2?

How can I get a list of all available products in Magento 2?
11
votes
3answers
11k views

Find out to which categories a product belongs to

I opened a product in the backend, but when I switch to the categories tab, the category tree is fully collapsed. I would have to expand all categories to see in which ones the product is in. How can ...
11
votes
2answers
14k views

Magento 2 : Bestseller and most viewed product on homepage

How to get bestseller and most viewed product in homepage Magento 2? We have to display bestseller and most viewed product list in homepage slider in magento 2.
10
votes
5answers
23k views

How to get products by stock qty?

I have the following code: umask(0); Mage::app(); $category =new Mage_Catalog_Model_Category(); $category->load($cid); if ($status == "2") { $products = Mage::getModel('catalog/product')->...
10
votes
2answers
13k views

How to get parent product id in magento 2?

How to get child's parent product id in magento2 for configurable product? I want to get parent product id of child product in magento based on child product id.
10
votes
5answers
21k views

Magento2 : How to get product id to my custom module

I am new to magento2 and currently I'm building a custom module and i want to get the product ID/SKU from the catalog. I'm trying to call using a function located in the Block folder. please advise!
10
votes
2answers
23k views

Magento2: Add custom template to product details page below add to cart section

I'm trying to add custom template to product page under social sharing section. In my module I've following code in layout file default.xml <body> <referenceContainer name="product.info....
10
votes
5answers
7k views

magento2 Invalid Form Key. Please refresh the page?

I am unable to save the product in magento2. it show "Invalid Form Key. Please refresh the page. in local how to resolve this?