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\...
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 //...
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/...
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 & ...
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 ...
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 ...
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/...
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 ...
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 ...
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 ...
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:
...
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-...
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 ...
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" ...
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/...
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 ...
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)
{
$...
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.
...
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 ...
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 ...
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 ...
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\...
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-...
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 ...
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 ...
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->...
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
&...
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 ...
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 ...
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 ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
related-products × 181magento2 × 73
magento-1.9 × 33
product × 21
up-sells × 18
configurable-product × 15
cross-sells × 12
magento2.3 × 11
product-collection × 10
magento-2.1 × 8
php × 7
addtocart × 7
products × 7
product-relations × 7
cart × 6
blocks × 6
custom × 6
magento-1.8 × 5
attributes × 5
magento-1 × 5
catalog × 5
product-view × 5
category × 4
template × 4
rules × 4