Questions tagged [product]

Denotes a question related to the Magento products.

Filter by
Sorted by
Tagged with
85 votes
6 answers
87k 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 ...
user avatar
  • 1,803
42 votes
1 answer
7k 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 ...
user avatar
  • 37.4k
39 votes
1 answer
15k 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....
user avatar
38 votes
7 answers
92k 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\...
user avatar
37 votes
1 answer
27k 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 ...
user avatar
  • 6,855
35 votes
4 answers
34k 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....
user avatar
  • 6,855
33 votes
7 answers
15k 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 ...
user avatar
  • 2,154
31 votes
5 answers
75k 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? // ...
user avatar
  • 1,736
30 votes
1 answer
158k 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\...
user avatar
  • 2,042
27 votes
4 answers
34k 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 ...
user avatar
27 votes
15 answers
46k views

Invalid Form Key. Please refresh the page?

I am unable to save the product in Magento 2. It shows "Invalid Form Key. Please refresh the page. in local how to resolve this?
user avatar
27 votes
4 answers
43k 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 ...
user avatar
26 votes
5 answers
49k 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 ?
user avatar
26 votes
13 answers
46k 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 $...
user avatar
  • 540
25 votes
2 answers
26k 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 ...
user avatar
24 votes
6 answers
51k views

How do I get the current product?

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 = $...
user avatar
24 votes
3 answers
15k 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->...
user avatar
  • 980
23 votes
11 answers
99k views

How to get product image and URL in Magento 2?

This is my observer: public function execute(\Magento\Framework\Event\Observer $observer) { $orderIds = $observer->getEvent()->getOrderIds(); $order = $this->...
user avatar
23 votes
2 answers
103k 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(); /** @...
user avatar
  • 682
21 votes
2 answers
24k views

Magento 2: Product URL Suffix

How do I remove the .html suffix from the product pages?
user avatar
  • 1,317
20 votes
4 answers
27k 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 ...
user avatar
  • 2,443
20 votes
1 answer
37k 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 ...
user avatar
19 votes
6 answers
10k 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 ?
user avatar
  • 597
18 votes
7 answers
69k views

Magento 2 - How to get attribute of product?

How to get attribute of product?
user avatar
  • 3,526
18 votes
2 answers
29k views

How to get the product type?

I'm creating a new module in Magento 2. I try to get product information in the phtml file. I have get successfully entity_id and product name information. but when I get product type information is ...
user avatar
  • 521
18 votes
5 answers
34k 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://...
user avatar
  • 1,481
18 votes
6 answers
8k 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 ...
user avatar
  • 2,689
17 votes
3 answers
16k 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?
user avatar
  • 14.7k
16 votes
5 answers
25k 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?
user avatar
  • 2,184
16 votes
4 answers
8k 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 ...
user avatar
  • 532
16 votes
6 answers
13k views

Magento 1 - 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 ...
user avatar
  • 3,535
16 votes
3 answers
18k 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/...
user avatar
16 votes
1 answer
1k 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 ...
user avatar
  • 1,712
15 votes
2 answers
9k 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 ...
user avatar
  • 161
15 votes
2 answers
11k 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(...
user avatar
15 votes
2 answers
2k views

Magento 1 - 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','...
user avatar
  • 1,257
15 votes
4 answers
5k 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) ...
user avatar
15 votes
1 answer
524 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 ...
user avatar
14 votes
4 answers
23k 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 ...
user avatar
14 votes
4 answers
23k views

Magento 2 How to Remove product information tabs

Please suggest how can we remove the "More Information" tabs from product details page See : http://awesomescreenshot.com/0f765e4128
user avatar
14 votes
8 answers
11k views

Where is the settings to check Use default Value in magento 2?

We have a Multiple website Magento 2 setup, We add product data in All store view and only change product price in individual store views. Now the problem is when we switch to store view, we have to ...
user avatar
14 votes
7 answers
17k 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 ...
user avatar
14 votes
4 answers
7k 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 ...
user avatar
  • 1,073
14 votes
1 answer
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 ...
user avatar
  • 243
13 votes
1 answer
19k views

magento 2 - How to get attribute set name in product listing and product detail page

How can we retrieve the attribute set name for a product. I want to use it on product detail and listing page.
user avatar
13 votes
3 answers
11k 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 ...
user avatar
  • 6,855
13 votes
2 answers
18k 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.
user avatar
12 votes
5 answers
24k views

Assign products to category programatically in magento2

How can I assign 'New products' to 'NEW PRODUCTS category' programatically in magento 2.
user avatar
  • 185
12 votes
2 answers
30k views

How to get parent product id in magento 2?

How to get a child's parent product id in Magento 2 for the configurable products? I want to get the parent product id of child product in Magento based on child product id.
user avatar
12 votes
2 answers
19k 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->...
user avatar
  • 348

1
2 3 4 5
98