13 votes
Accepted

Magento 2 : How to display swatches in related products?

In app/design/frontend/MyCompany/mytheme/Magento_Catalog/templates/product/list/items.phtml please add below code : <?php if($_item->getTypeId() == \Magento\ConfigurableProduct\Model\Product\...
Charvi Parikh's user avatar
11 votes
Accepted

set related/upsell products programatically only works for 1 product

This part caused your issue, if you created this object outsize the foreach loop, that means it is a "global" object. So, we need to create a new object inside the loop. $linkData = $productLinks //...
Khoa TruongDinh's user avatar
8 votes
Accepted

Related Products template customize

By default, Magento uses the same template for product related, upsell, crosssel and new products content widget. This template comes from vendor/magento/module-catalog/view/frontend/templates/product/...
Khoa TruongDinh's user avatar
7 votes

CSV Import: How can I import related products in Magento 2?

We've experienced the same issue, it seems import module has some kind of bug with related products We've solved it by writing a new console command which expects a 2 columns (parent sku & ...
Raul Sanchez's user avatar
  • 3,217
7 votes
Accepted

How to move related products at very bottom of product page?

By default Related products show in content.aside container, which is render after content container. Both content.aside and content comes in main container, So you can move related product after ...
Pawan's user avatar
  • 5,826
6 votes

How to show related products in product view page in Magento 2?

Adding related product in Magento 2 is very easy. Here are steps Admin -> Product(left sidebar) -> Catalog Click on Edit link under Action tab. Go to Related Products, Up-Sells, and Cross-Sells ...
Jarnail S's user avatar
  • 4,687
6 votes
Accepted

Magento 2 How to add custom product relations?

Magento 2.0.x version: First of all, there are some notes: --Replaced event catalog_product_prepare_save with controller product initialization helper that can be customized via plugins - Vendor/...
Khoa TruongDinh's user avatar
6 votes

Magento 2 : How to display swatches in related products?

In 2.2.5 we're doing the following to achieve the swatches, essentially it replicates the code from the Mage_Catalog::product/list.phtml template where swatches are by default. Firstly you need to ...
Adam Johnson's user avatar
5 votes
Accepted

how to add default products to related products list

You can write an observer for catalog_product_collection_load_after, then add products to the loaded collection if the collection is the related products collection: use Mage_Catalog_Model_Product as ...
Fabian Schmengler's user avatar
5 votes

how to add default products to related products list

You can do this with the help of a custom observer method. To do so, call your observer's function at event catalog_product_save_after. By using this, whenever a product will be saved from admin ...
Mohit Kumar Arora's user avatar
5 votes
Accepted

Magento 2.3: Error Assigning Related Products

I was able to fix this: First check the following tables in your DB: catalog_product_link_attribute and catalog_product_link_type If those are empty, you need to run the following SQL queries: ...
AJK's user avatar
  • 741
4 votes

Magento 2 - Quantity Field on Related Products Listing

Replace the content of if ($showCart) ...... endif with below code. <?php if ($showCart): ?> <div class="product actions product-item-actions"> <form data-role="tocart-...
Jarnail S's user avatar
  • 4,687
4 votes
Accepted

How to get the thumbnail image with getAttributeRawValue

The attribute thumbnail will give you the filename of the image to use as a thumbnail for the product. There's no constraints on the size of that image though and you're trying to resize the image ...
Richard's user avatar
  • 1,724
4 votes

How to show related products in product view page in Magento 2?

I presume you are falling back to the blank or Luma theme? If this is the case you need to move the related products using the <move> XML. <move element="catalog.product.related" ...
Ben Crook's user avatar
  • 15.6k
4 votes

Magento 2 : How to display swatches in related products?

To display Swatches along with the product name, thumbnail, etc, just like on the Category product lists, I did this in my Theme: Create this file: app/design/frontend/MyCompany/mytheme/...
thaddeusmt's user avatar
  • 1,385
4 votes
Accepted

Need to show related products of simple product in configurable product

If you want to display related products of child items instead of the related products of the parent item in a configurable product structure, then Create a new module and override _prepareData ...
Hammad Khalid's user avatar
4 votes
Accepted

Magento 1.9.3.X: Get all related products of a product

You can get the related products of a product by using the below code in your script. try { $configProductIds = [1663]; foreach ($configProductIds as $product_id) { $...
Sumit's user avatar
  • 4,825
3 votes
Accepted

Magento related products disappears with item max qty in cart

The products should not appear in related or upsells if they are already in the cart. The qty that is in the cart is not important in this case. Here is how it works in the Related.php block. ...
Marius's user avatar
  • 198k
3 votes
Accepted

Custom Block generating an error on template: Magento

After trying to execute the given SQL query in phpmyadmin for a default Magento database, I got the following error: #1054 - Unknown column 'e.name' in 'field list' What this means is that the ...
V.S's user avatar
  • 904
3 votes
Accepted

Magento 1.9 not able to save upsell/related/cross sell products

I am guessing that you are using Google Chrome so you might want to try firefox. The upsell, cross sell, and related products tabs are loaded via ajax and due to the way different browsers handle ...
Shawn Abramson's user avatar
3 votes
Accepted

Where is related product place in Magento2?

Html file is called from Catalog module. magento2.1/vendor/magento/module-catalog/view/frontend/templates/product/list/items.phtml Related, Upsell and cross sell product display inside detail page ...
Rakesh Jesadiya's user avatar
3 votes
Accepted

Move related products to custom div in custom phtml template

Move the element in your layout xml: <move element="catalog.product.related" destination="configurator"/> <referenceContainer name="page.wrapper"> <block class="Magento\Catalog\...
steros's user avatar
  • 1,622
3 votes

How to move reivew block after related product in magento 2?

Go To you theme Directory app/design/frontend///Magento_Catalog/layout/catalog_product_view.xml <?xml version="1.0"?> <page layout="1column" xmlns:xsi="http://www.w3.org/2001/XMLSchema-...
Vinit Kumar's user avatar
3 votes
Accepted

Magento : Add product qty box in related product

You need to first add qty field in related_product.phtml file then rewrite function public function addAction() in file app/code/core/Mage/Checkout/controllers/CartController.php in this method ...
Shashank Kumrawat's user avatar
3 votes

Magento 2 - How to show related products in a thumbnail slider?

I assume that you are using a custom theme name Vendor_customtheme You can follow the below steps to implement OwlCarousel Slider for Related Product in the product detail page. Note: Below example ...
Pritam Biswas's user avatar
3 votes
Accepted

Get Configurable Product options, Price And Add to cart Button On Related Product Section

You can create same controller as default addToCart controller. public function execute() { $currentStore = $this->storeManager->getStore(); $baseUrl = $currentStore->...
anonymous's user avatar
  • 3,724
3 votes
Accepted

Magento 2.3 - Get category of item related foreach

Create a module and override catalog_product_view.xml in your module. then create one block to set your business logic to the template. Vendor/Module/view/frontend/layout/catalog_product_view.xml &...
Devidas's user avatar
  • 3,328
2 votes

Add to cart button in related products leads to some view source page

It seams that you have an extension for adding products to cart via AJAX. This means your addAction from the cart controller is rewritten. Either disable the extension or find out the js function that ...
Marius's user avatar
  • 198k
2 votes

Configurable Options in Related Products - Fatal error: Call to a member function getAttributeCode() on a > non-object

This is doable, but it requires a lot of work. You should ask yourself if is is worth the effort ;) I do, sometimes. You need to ensure all the selectable options are unique. As was mentioned in the ...
ProxiBlue's user avatar
  • 9,926
2 votes

Re-save entire catalog's related products field via SSH php script?

This defines the Resave_Products class but does not do anything. Add the following at the bottom: $shell = new Resave_Products(); $shell->run(); If you have a look at the other files in /shell ...
Fabian Schmengler's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible