Questions tagged [product]

Denotes a question related to the Magento products.

Filter by
Sorted by
Tagged with
18
votes
6answers
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 ...
82
votes
6answers
73k 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 ...
9
votes
1answer
10k views

How do disable caching of custom block on product view page?

I have customBlock in product_view. How do disable cache for this?
6
votes
7answers
5k views

My Custom product tab not displaying in Magento 2

I am trying to inject my custom product tab in storefront on product view page, but it's not displaying. For this I am written below code. registration.php <?php \Magento\Framework\Component\...
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 ...
33
votes
4answers
32k 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....
25
votes
2answers
25k 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 ...
25
votes
1answer
101k 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\...
3
votes
2answers
5k views

Magento 2: Save all product data outside Magento with Images

I have below code with Image Upload which is working fine. But images are not stored in Database Table as mentioned in Order. include('app/bootstrap.php'); use Magento\Framework\App\Bootstrap; $...
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 ...
2
votes
1answer
3k views

Magento 1.9 How to add buy now button in product page?

I am using magento 1.9, I want to add BUY NOW button on product details page, Buy now button redirect to checkout page. I tried many solution already solved in this forum, But all the solutions are ...
38
votes
1answer
14k 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....
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 ...
9
votes
6answers
11k views

Configurable product attribute sort order in Dropdown 2.12

The order of the dropdown is not consistent with the order of the attribute itself. Within the attribute size I have it ordered Newborn 0-3 mo and in the dropdown it shows up as 0-3 Newborn the ...
7
votes
2answers
12k views

Magento 2: Set Custom product attribute value programmatically on product save

How to set a product's custom attribute on save? I have used the event/observer way but nothing works.
11
votes
7answers
14k views

Why the error when creating a new product “Asymmetric transaction rollback.”?

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 :)
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 ...
24
votes
3answers
14k 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->...
15
votes
2answers
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(...
19
votes
1answer
35k 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 ...
19
votes
2answers
19k views

Magento 2: Product URL Suffix

How do I remove the .html suffix from the product pages?
13
votes
2answers
15k 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.
22
votes
4answers
35k 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 ?
15
votes
6answers
46k views

Magento 2 - How to get attribute of product?

How to get attribute of product?
6
votes
5answers
27k views

Get product attribute 'option label'?

I have manage to retrieve the value for an attribute relative to a particular product $store_id = Mage::app()->getStore()->getStoreId(); $attribute_code = 'code'; $value = Mage::...
30
votes
7answers
54k 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\...
1
vote
2answers
2k views

Disable merging of cart positions?

Is it possible to disable the merging of same products into one position in the cart? So when someone adds Product ABC with Qty 1 to the cart, continues shopping and adds the same product again with ...
1
vote
1answer
6k views

Product Types: custom options vs bundle vs configurable

I am about to start working on a shop that has around 1000 products, which normally is nice and easy. Some are simple products (no problem here) but around half have the possibility to be configured. ...
4
votes
3answers
5k views

Magento - Rename Tax to GST

Throughout my Magento website, where there are products, I made it so that a customer can see the price of the products, with and without Tax. However, how can I rename the word 'Tax' to 'GST' ...
42
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 ...
11
votes
4answers
14k 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?
24
votes
13answers
33k 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 $...
17
votes
4answers
31k 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 = $...
16
votes
5answers
47k 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->...
6
votes
3answers
5k 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 ...
4
votes
2answers
9k views

show random products from a category

On my cart page i have a little display, which shows products from a certain category, it displays 4 products, but in my category i have 8-10 products. How can i make it select random products so it ...
11
votes
5answers
27k 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!
9
votes
1answer
12k 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.
3
votes
1answer
13k views

Magento 2 programatically add product to cart? [duplicate]

We have a requirement that we wants to add product to cart programmatically in magento2.
3
votes
2answers
10k views

Issue with getting product image

Consider the example code found in my own block file: public function getImages() { $images = array(); $products = Mage::getModel('catalog/product') ->getCollection() ->...
3
votes
3answers
5k views

Magento 2 : How To Show Price of “out of stock” Products

I want to show the price of product, that is "out of stock". Currently it is not shown price for the products in my magento 2.1.3 installation. How to make visible it?
1
vote
1answer
3k views

Theme error in Magento

I'm trying to add products to a page. I used this code in contents of the page. <p>{{block type="catalog/product_list" category_id="4" template="catalog/product/list.phtml"}}</p>. And I ...
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 ...
7
votes
5answers
28k views

programmatically adding product to cart returns empty price

i have been trying to programmatically add a product to cart using following lines of code, it seems to work and successfully adds product but for some reason, the price of newly added product always ...
9
votes
5answers
10k views

Find Products with No Images

Is it possible to run a query to find a list of products with no images assigned to them? Ideally I'd like SKUs printed out on the screen.
9
votes
5answers
13k views

Assign products to category programatically in magento2

How can I assign 'New products' to 'NEW PRODUCTS category' programatically in magento 2.
13
votes
9answers
16k 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?
6
votes
4answers
3k views

Undefined index “media_type” while adding image to product's media gallery

Here is the code snippet I use to add an image in a product's media gallery : $sku = 'product-example-sku'; $image_url = 'http://example.com/image.jpg'; $image_ext = pathinfo($image_url, ...
4
votes
1answer
13k views

Create CSV list of all products & their categories

can somebody suggest me a way or a script to export a csv file with all product SKUs & the categories those SKUs are associated to? I've tried several things... but nothing seems to work. ...
3
votes
2answers
3k views

Magento 2 : get best seller product on daily basis

There are some tables related to bestseller in Magento 2 and it is using following tables to get best product collection. sales_bestsellers_aggregated_daily sales_bestsellers_aggregated_monthly ...

1
2 3 4 5
9