Questions tagged [product]

Denotes a question related to the Magento products.

Filter by
Sorted by
Tagged with
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 ...
9
votes
1answer
9k views

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

I have customBlock in product_view. How do disable cache for this?
5
votes
7answers
4k 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 ...
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 ...
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....
24
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 ...
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; $...
23
votes
1answer
86k 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\...
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 ...
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....
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
10k 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 ...
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 :)
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 ...
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->...
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(...
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
2answers
16k views

Magento 2: Product URL Suffix

How do I remove the .html suffix from the product pages?
12
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.
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::...
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. ...
6
votes
2answers
8k 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.
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' ...
21
votes
4answers
31k 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 ?
14
votes
6answers
39k views

Magento 2 - How to get attribute of product?

How to get attribute of product?
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?
23
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 $...
15
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 = $...
26
votes
7answers
45k 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\...
5
votes
3answers
4k 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 ...
2
votes
2answers
3k views

Magento 2 - How To Display Cross Sell Products On Product Details Page (PDP)?

I need to show cross sell products on pdp (Product Detail Page ) page , like currently related products shows , hows it possible ?
10
votes
5answers
22k 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!
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() ->...
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 ...
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 ...
7
votes
5answers
27k 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
9k 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.
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, ...
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 ...
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 ?
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 ...
5
votes
2answers
4k views

Magento Enterprise: catalog_product_attribute not reindexed on product save

I'm using Magento ee 1.13.0.2 and discovering the next problem: I have some of the attributes used in layered navigation - color and size. When I add a new product (simple one) and save it - product ...
4
votes
4answers
6k views

show attributes in description.phtml

I found it is hard to show the attributes in Description.phtml,it is hard to me. i wish to show some attributes as Brand,Color,Name in Description.phtml ,i copied the attributes.phtml and change some ...
2
votes
1answer
3k views

Product attributes and label attribute group

I would like to show the various attributes divided into groups as created in the set of attributes, such as general attribute 1 attribute 2 ... other info attribute 1 attribute 2 ... How do ...
9
votes
1answer
7k views

How to import related products in normal import process?

How to import related products in normal import process? How can I achieve this? Is there any method available for import related products?