How to show both at same time Upsell and Related Products In Product View Page Magento 2 Unicorn Meta Zoo #1: Why another podcast? Announcing the arrival of Valued Associate #679: Cesar ManaraShow configurable products on product info pageConfigurable items in related and upsell areasHow to show related products in product view page in Magento 2?Magento 2 : Related Products in product view pageMagento 2 : Display Related Products Block in Product ViewHow to create slider for Upsell product and keep related items in simple grid view?Magento 2 UPSELL product list showing same price as of ProductHow the upsell products handled in view page?function override issue in foreach loop while importing upsell and related products in magento2How to override product details view price section magento 2?
"My boss was furious with me and I have been fired" vs. "My boss was furious with me and I was fired"
Why didn't the Space Shuttle bounce back into space as many times as possible so as to lose a lot of kinetic energy up there?
Is a 5 watt UHF/VHF handheld considered QRP?
Mistake in years of experience in resume?
Retract an already submitted recommendation letter (written for an undergrad student)
Prove the alternating sum of a decreasing sequence converging to 0 is Cauchy.
Contradiction proof for inequality of P and NP?
How to translate "red flag" into Spanish?
Additive group of local rings
How long after the last departure shall the airport stay open for an emergency return?
Is accepting an invalid credit card number a security issue?
Are all CP/M-80 implementations binary compatible?
My admission is revoked after accepting the admission offer
With indentation set to `0em`, when using a line break, there is still an indentation of a size of a space
PIC mathematical operations weird problem
What ability score does a Hexblade's Pact Weapon use for attack and damage when wielded by another character?
Arriving in Atlanta after US Preclearance in Dublin. Will I go through TSA security in Atlanta to transfer to a connecting flight?
How to open locks without disable device?
What's parked in Mil Moscow helicopter plant?
Multiple options vs single option UI
Does Feeblemind produce an ongoing magical effect that can be dispelled?
Do I need to protect SFP ports and optics from dust/contaminants? If so, how?
Multiple fireplaces in an apartment building?
Are there moral objections to a life motivated purely by money? How to sway a person from this lifestyle?
How to show both at same time Upsell and Related Products In Product View Page Magento 2
Unicorn Meta Zoo #1: Why another podcast?
Announcing the arrival of Valued Associate #679: Cesar ManaraShow configurable products on product info pageConfigurable items in related and upsell areasHow to show related products in product view page in Magento 2?Magento 2 : Related Products in product view pageMagento 2 : Display Related Products Block in Product ViewHow to create slider for Upsell product and keep related items in simple grid view?Magento 2 UPSELL product list showing same price as of ProductHow the upsell products handled in view page?function override issue in foreach loop while importing upsell and related products in magento2How to override product details view price section magento 2?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I want to show Related and Upsell both at the same time in my product view page.
I tried to change catalog_product_view.xml many times, but it displays me only upsell products not related.
anyone, please help
magento2 php-7 related-products up-sells
add a comment |
I want to show Related and Upsell both at the same time in my product view page.
I tried to change catalog_product_view.xml many times, but it displays me only upsell products not related.
anyone, please help
magento2 php-7 related-products up-sells
add a comment |
I want to show Related and Upsell both at the same time in my product view page.
I tried to change catalog_product_view.xml many times, but it displays me only upsell products not related.
anyone, please help
magento2 php-7 related-products up-sells
I want to show Related and Upsell both at the same time in my product view page.
I tried to change catalog_product_view.xml many times, but it displays me only upsell products not related.
anyone, please help
magento2 php-7 related-products up-sells
magento2 php-7 related-products up-sells
edited 2 days ago
Navin Bhudiya
8391125
8391125
asked 2 days ago
Xain IjazXain Ijaz
133
133
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
You may try the steps below.
Assume you are using a custom module (if not please create a custom module) named "Company_MyModule".
step 1) Create a block class MycrossUpsell.php under /app/code/Company/MyModule/Block
FIle:/app/code/Company/MyModule/Block/MycrossUpsell.php
<?php
namespace CompanyMyModuleBlock;
class MycrossUpsell extends MagentoCatalogBlockProductAbstractProduct implements MagentoFrameworkDataObjectIdentityInterface
/**
* @var Collection
*/
protected $_itemCollection;
/**
* Checkout session
*
* @var MagentoCheckoutModelSession
*/
protected $_checkoutSession;
/**
* Catalog product visibility
*
* @var MagentoCatalogModelProductVisibility
*/
protected $_catalogProductVisibility;
/**
* Checkout cart
*
* @var MagentoCheckoutModelResourceModelCart
*/
protected $_checkoutCart;
/**
* @var MagentoFrameworkModuleManager
*/
protected $moduleManager;
protected $_registry;
/**
* @param MagentoCatalogBlockProductContext $context
* @param MagentoCheckoutModelResourceModelCart $checkoutCart
* @param MagentoCatalogModelProductVisibility $catalogProductVisibility
* @param MagentoCheckoutModelSession $checkoutSession
* @param MagentoFrameworkModuleManager $moduleManager
* @param array $data
*/
public function __construct(
MagentoCatalogBlockProductContext $context,
MagentoCheckoutModelResourceModelCart $checkoutCart,
MagentoCatalogModelProductVisibility $catalogProductVisibility,
MagentoCheckoutModelSession $checkoutSession,
MagentoFrameworkModuleManager $moduleManager,
MagentoFrameworkRegistry $registry,
array $data = []
)
$this->_checkoutCart = $checkoutCart;
$this->_catalogProductVisibility = $catalogProductVisibility;
$this->_checkoutSession = $checkoutSession;
$this->moduleManager = $moduleManager;
$this->_registry = $registry;
parent::__construct(
$context,
$data
);
public function getCurrentProduct()
return $this->_registry->registry('current_product');
public function getRelatedProducts()
$product = $this->_coreRegistry->registry('product');
/* @var $product MagentoCatalogModelProduct */
$this->_itemCollection = $product->getRelatedProductCollection()->addAttributeToSelect(
'required_options'
)->setPositionOrder()->addStoreFilter();
if ($this->moduleManager->isEnabled('Magento_Checkout'))
$this->_addProductAttributesAndPrices($this->_itemCollection);
$this->_itemCollection->setVisibility($this->_catalogProductVisibility->getVisibleInCatalogIds());
$this->_itemCollection->load();
foreach ($this->_itemCollection as $product)
$product->setDoNotUseCategoryId(true);
return $this->_itemCollection;
public function getUpsellProducts()
$product = $this->_coreRegistry->registry('product');
/* @var $product MagentoCatalogModelProduct */
$this->_itemCollection = $product->getUpSellProductCollection()->addAttributeToSelect(
'required_options'
)->setPositionOrder()->addStoreFilter();
if ($this->moduleManager->isEnabled('Magento_Checkout'))
$this->_addProductAttributesAndPrices($this->_itemCollection);
$this->_itemCollection->setVisibility($this->_catalogProductVisibility->getVisibleInCatalogIds());
$this->_itemCollection->load();
foreach ($this->_itemCollection as $product)
$product->setDoNotUseCategoryId(true);
return $this->_itemCollection;
/**
* @return Collection
*/
public function getItems()
/**
* getIdentities() depends on _itemCollection populated, but it can be empty if the block is hidden
* @see https://github.com/magento/magento2/issues/5897
*/
if ($this->_itemCollection === null)
$this->_prepareData();
return $this->_itemCollection;
/**
* Return identifiers for produced content
*
* @return array
*/
public function getIdentities()
$identities = [];
foreach ($this->getItems() as $item)
$identities = array_merge($identities, $item->getIdentities());
return $identities;
/**
* Find out if some products can be easy added to cart
*
* @return bool
*/
public function canItemsAddToCart()
foreach ($this->getItems() as $item)
if (!$item->isComposite() && $item->isSaleable() && !$item->getRequiredOptions())
return true;
return false;
?>
step 2 : Create phtml file cross_upsell.phtml under /app/code/Company/MyModule/view/frontend/templates/product/view
File : /app/code/Company/MyModule/view/frontend/templates/product/view/cross_upsell.phtml
<?php
$type = 'related';
$class = $type;
$image = 'related_products_list';
$title = __('Related Products');
$items = $block->getRelatedProducts(); //$block->getAllItems();
$limit = $block->getPositionLimit();
$shuffle = 0;//(int) $block->isShuffled();
$canItemsAddToCart = $block->canItemsAddToCart();
$showAddTo = true;
$showCart = false;
$templateType = null;
$description = false;
?>
<h2><?php echo $title; ?></h2>
<div class="block-title title">
<strong id="block-<?= /* @escapeNotVerified */ $class ?>-heading" role="heading" aria-level="2"><?= /* @escapeNotVerified */ $title ?></strong>
</div>
<div class="block-content content" aria-labelledby="block-<?= /* @escapeNotVerified */ $class ?>-heading">
<div class="products wrapper grid products-grid products-<?= /* @escapeNotVerified */ $type ?>">
<ol class="products list items product-items">
<?php $iterator = 1; ?>
<?php foreach ($items as $_item): ?>
<?php $available = ''; ?>
<?php if (!$_item->isComposite() && $_item->isSaleable() && $type == 'related'): ?>
<?php if (!$_item->getRequiredOptions()): ?>
<?php $available = 'related-available'; ?>
<?php endif; ?>
<?php endif; ?>
<div class="product-item-info <?= /* @escapeNotVerified */ $available ?>">
<?= /* @escapeNotVerified */ '<!-- ' . $image . '-->' ?>
<a href="<?= /* @escapeNotVerified */ $block->getProductUrl($_item) ?>" class="product photo product-item-photo">
<?= $block->getImage($_item, $image)->toHtml() ?>
</a>
<div class="product details product-item-details">
<strong class="product name product-item-name"><a class="product-item-link" title="<?= $block->escapeHtml($_item->getName()) ?>" href="<?= /* @escapeNotVerified */ $block->getProductUrl($_item) ?>">
<?= $block->escapeHtml($_item->getName()) ?></a>
</strong>
<?= /* @escapeNotVerified */ $block->getProductPrice($_item) ?>
<?php if ($templateType): ?>
<?= $block->getReviewsSummaryHtml($_item, $templateType) ?>
<?php endif; ?>
<?php if ($canItemsAddToCart && !$_item->isComposite() && $_item->isSaleable() && $type == 'related'): ?>
<?php if (!$_item->getRequiredOptions()): ?>
<div class="field choice related">
<input type="checkbox" class="checkbox related" id="related-checkbox<?= /* @escapeNotVerified */ $_item->getId() ?>" name="related_products[]" value="<?= /* @escapeNotVerified */ $_item->getId() ?>" />
<label class="label" for="related-checkbox<?= /* @escapeNotVerified */ $_item->getId() ?>"><span><?= /* @escapeNotVerified */ __('Add to Cart') ?></span></label>
</div>
<?php endif; ?>
<?php endif; ?>
<?php if ($showAddTo || $showCart): ?>
<div class="product actions product-item-actions">
<?php if ($showCart): ?>
<div class="actions-primary">
<?php if ($_item->isSaleable()): ?>
<?php if ($_item->getTypeInstance()->hasRequiredOptions($_item)): ?>
<button class="action tocart primary" data-mage-init='"redirectUrl": "url": "<?= /* @escapeNotVerified */ $block->getAddToCartUrl($_item) ?>"' type="button" title="<?= /* @escapeNotVerified */ __('Add to Cart') ?>">
<span><?= /* @escapeNotVerified */ __('Add to Cart') ?></span>
</button>
<?php else: ?>
<?php $postDataHelper = $this->helper('MagentoFrameworkDataHelperPostHelper');
$postData = $postDataHelper->getPostData($block->getAddToCartUrl($_item), ['product' => $_item->getEntityId()])
?>
<button class="action tocart primary"
data-post='<?= /* @escapeNotVerified */ $postData ?>'
type="button" title="<?= /* @escapeNotVerified */ __('Add to Cart') ?>">
<span><?= /* @escapeNotVerified */ __('Add to Cart') ?></span>
</button>
<?php endif; ?>
<?php else: ?>
<?php if ($_item->getIsSalable()): ?>
<div class="stock available"><span><?= /* @escapeNotVerified */ __('In stock') ?></span></div>
<?php else: ?>
<div class="stock unavailable"><span><?= /* @escapeNotVerified */ __('Out of stock') ?></span></div>
<?php endif; ?>
<?php endif; ?>
</div>
<?php endif; ?>
<?php if ($showAddTo): ?>
<div class="secondary-addto-links actions-secondary" data-role="add-to-links">
<?php if ($addToBlock = $block->getChildBlock('addto')): ?>
<?= $addToBlock->setProduct($_item)->getChildHtml() ?>
<?php endif; ?>
</div>
<?php endif; ?>
</div>
<?php endif; ?>
</div>
</div>
<?= ($iterator == count($items)+1) ? '</li>' : '' ?>
<?php endforeach ?>
</ol>
</div>
</div>
</div>
<?php
$type = 'upsell';
$class = $type;
$image = 'upsell_products_list';
$title = __('We found other products you might like!');
$items = $block->getUpsellProducts();
$limit = $block->getItemLimit('upsell');
$shuffle = 0;
$showAddTo = false;
$showCart = false;
$templateType = null;
$description = false;
$canItemsAddToCart = false;
?>
<h2><?php echo $title; ?></h2>
<div class="products wrapper">
<div class="products list items product-items">
<?php $iterator = 1; ?>
<?php foreach ($items as $_item): ?>
<?php $available = ''; ?>
<div class="product-item-info>
<?= /* @escapeNotVerified */ '<!-- ' . $image . '-->' ?>
<a href="<?= /* @escapeNotVerified */ $block->getProductUrl($_item) ?>" class="product photo product-item-photo">
<?= $block->getImage($_item, $image)->toHtml() ?>
</a>
<div class="product details product-item-details">
<strong class="product name product-item-name"><a class="product-item-link" title="<?= $block->escapeHtml($_item->getName()) ?>" href="<?= /* @escapeNotVerified */ $block->getProductUrl($_item) ?>">
<?= $block->escapeHtml($_item->getName()) ?></a>
</strong>
<?= /* @escapeNotVerified */ $block->getProductPrice($_item) ?>
<?php if ($templateType): ?>
<?= $block->getReviewsSummaryHtml($_item, $templateType) ?>
<?php endif; ?>
<?php if ($canItemsAddToCart && !$_item->isComposite() && $_item->isSaleable() && $type == 'related'): ?>
<?php if (!$_item->getRequiredOptions()): ?>
<div class="field choice related">
<input type="checkbox" class="checkbox related" id="related-checkbox<?= /* @escapeNotVerified */ $_item->getId() ?>" name="related_products[]" value="<?= /* @escapeNotVerified */ $_item->getId() ?>" />
<label class="label" for="related-checkbox<?= /* @escapeNotVerified */ $_item->getId() ?>"><span><?= /* @escapeNotVerified */ __('Add to Cart') ?></span></label>
</div>
<?php endif; ?>
<?php endif; ?>
<?php if ($showAddTo || $showCart): ?>
<div class="product actions product-item-actions">
<?php if ($showCart): ?>
<div class="actions-primary">
<?php if ($_item->isSaleable()): ?>
<?php if ($_item->getTypeInstance()->hasRequiredOptions($_item)): ?>
<button class="action tocart primary" data-mage-init='"redirectUrl": "url": "<?= /* @escapeNotVerified */ $block->getAddToCartUrl($_item) ?>"' type="button" title="<?= /* @escapeNotVerified */ __('Add to Cart') ?>">
<span><?= /* @escapeNotVerified */ __('Add to Cart') ?></span>
</button>
<?php else: ?>
<?php $postDataHelper = $this->helper('MagentoFrameworkDataHelperPostHelper');
$postData = $postDataHelper->getPostData($block->getAddToCartUrl($_item), ['product' => $_item->getEntityId()])
?>
<button class="action tocart primary"
data-post='<?= /* @escapeNotVerified */ $postData ?>'
type="button" title="<?= /* @escapeNotVerified */ __('Add to Cart') ?>">
<span><?= /* @escapeNotVerified */ __('Add to Cart') ?></span>
</button>
<?php endif; ?>
<?php else: ?>
<?php if ($_item->getIsSalable()): ?>
<div class="stock available"><span><?= /* @escapeNotVerified */ __('In stock') ?></span></div>
<?php else: ?>
<div class="stock unavailable"><span><?= /* @escapeNotVerified */ __('Out of stock') ?></span></div>
<?php endif; ?>
<?php endif; ?>
</div>
<?php endif; ?>
<?php if ($showAddTo): ?>
<div class="secondary-addto-links actions-secondary" data-role="add-to-links">
<?php if ($addToBlock = $block->getChildBlock('addto')): ?>
<?= $addToBlock->setProduct($_item)->getChildHtml() ?>
<?php endif; ?>
</div>
<?php endif; ?>
</div>
<?php endif; ?>
</div>
</div>
</div>
<?php endforeach ?>
</div>
</div>
Note: Please change PHTML pages code as per your design needs.
step 3: Run the following commands from your Magento root and check the product details page
sudo php bin/magento setup:di:compile
sudo php bin/magento cache:flush
Thanks @Pritam it worked
– Xain Ijaz
2 days ago
Welcome @XainIjaz
– Pritam Info 24
2 days ago
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "479"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f270934%2fhow-to-show-both-at-same-time-upsell-and-related-products-in-product-view-page-m%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You may try the steps below.
Assume you are using a custom module (if not please create a custom module) named "Company_MyModule".
step 1) Create a block class MycrossUpsell.php under /app/code/Company/MyModule/Block
FIle:/app/code/Company/MyModule/Block/MycrossUpsell.php
<?php
namespace CompanyMyModuleBlock;
class MycrossUpsell extends MagentoCatalogBlockProductAbstractProduct implements MagentoFrameworkDataObjectIdentityInterface
/**
* @var Collection
*/
protected $_itemCollection;
/**
* Checkout session
*
* @var MagentoCheckoutModelSession
*/
protected $_checkoutSession;
/**
* Catalog product visibility
*
* @var MagentoCatalogModelProductVisibility
*/
protected $_catalogProductVisibility;
/**
* Checkout cart
*
* @var MagentoCheckoutModelResourceModelCart
*/
protected $_checkoutCart;
/**
* @var MagentoFrameworkModuleManager
*/
protected $moduleManager;
protected $_registry;
/**
* @param MagentoCatalogBlockProductContext $context
* @param MagentoCheckoutModelResourceModelCart $checkoutCart
* @param MagentoCatalogModelProductVisibility $catalogProductVisibility
* @param MagentoCheckoutModelSession $checkoutSession
* @param MagentoFrameworkModuleManager $moduleManager
* @param array $data
*/
public function __construct(
MagentoCatalogBlockProductContext $context,
MagentoCheckoutModelResourceModelCart $checkoutCart,
MagentoCatalogModelProductVisibility $catalogProductVisibility,
MagentoCheckoutModelSession $checkoutSession,
MagentoFrameworkModuleManager $moduleManager,
MagentoFrameworkRegistry $registry,
array $data = []
)
$this->_checkoutCart = $checkoutCart;
$this->_catalogProductVisibility = $catalogProductVisibility;
$this->_checkoutSession = $checkoutSession;
$this->moduleManager = $moduleManager;
$this->_registry = $registry;
parent::__construct(
$context,
$data
);
public function getCurrentProduct()
return $this->_registry->registry('current_product');
public function getRelatedProducts()
$product = $this->_coreRegistry->registry('product');
/* @var $product MagentoCatalogModelProduct */
$this->_itemCollection = $product->getRelatedProductCollection()->addAttributeToSelect(
'required_options'
)->setPositionOrder()->addStoreFilter();
if ($this->moduleManager->isEnabled('Magento_Checkout'))
$this->_addProductAttributesAndPrices($this->_itemCollection);
$this->_itemCollection->setVisibility($this->_catalogProductVisibility->getVisibleInCatalogIds());
$this->_itemCollection->load();
foreach ($this->_itemCollection as $product)
$product->setDoNotUseCategoryId(true);
return $this->_itemCollection;
public function getUpsellProducts()
$product = $this->_coreRegistry->registry('product');
/* @var $product MagentoCatalogModelProduct */
$this->_itemCollection = $product->getUpSellProductCollection()->addAttributeToSelect(
'required_options'
)->setPositionOrder()->addStoreFilter();
if ($this->moduleManager->isEnabled('Magento_Checkout'))
$this->_addProductAttributesAndPrices($this->_itemCollection);
$this->_itemCollection->setVisibility($this->_catalogProductVisibility->getVisibleInCatalogIds());
$this->_itemCollection->load();
foreach ($this->_itemCollection as $product)
$product->setDoNotUseCategoryId(true);
return $this->_itemCollection;
/**
* @return Collection
*/
public function getItems()
/**
* getIdentities() depends on _itemCollection populated, but it can be empty if the block is hidden
* @see https://github.com/magento/magento2/issues/5897
*/
if ($this->_itemCollection === null)
$this->_prepareData();
return $this->_itemCollection;
/**
* Return identifiers for produced content
*
* @return array
*/
public function getIdentities()
$identities = [];
foreach ($this->getItems() as $item)
$identities = array_merge($identities, $item->getIdentities());
return $identities;
/**
* Find out if some products can be easy added to cart
*
* @return bool
*/
public function canItemsAddToCart()
foreach ($this->getItems() as $item)
if (!$item->isComposite() && $item->isSaleable() && !$item->getRequiredOptions())
return true;
return false;
?>
step 2 : Create phtml file cross_upsell.phtml under /app/code/Company/MyModule/view/frontend/templates/product/view
File : /app/code/Company/MyModule/view/frontend/templates/product/view/cross_upsell.phtml
<?php
$type = 'related';
$class = $type;
$image = 'related_products_list';
$title = __('Related Products');
$items = $block->getRelatedProducts(); //$block->getAllItems();
$limit = $block->getPositionLimit();
$shuffle = 0;//(int) $block->isShuffled();
$canItemsAddToCart = $block->canItemsAddToCart();
$showAddTo = true;
$showCart = false;
$templateType = null;
$description = false;
?>
<h2><?php echo $title; ?></h2>
<div class="block-title title">
<strong id="block-<?= /* @escapeNotVerified */ $class ?>-heading" role="heading" aria-level="2"><?= /* @escapeNotVerified */ $title ?></strong>
</div>
<div class="block-content content" aria-labelledby="block-<?= /* @escapeNotVerified */ $class ?>-heading">
<div class="products wrapper grid products-grid products-<?= /* @escapeNotVerified */ $type ?>">
<ol class="products list items product-items">
<?php $iterator = 1; ?>
<?php foreach ($items as $_item): ?>
<?php $available = ''; ?>
<?php if (!$_item->isComposite() && $_item->isSaleable() && $type == 'related'): ?>
<?php if (!$_item->getRequiredOptions()): ?>
<?php $available = 'related-available'; ?>
<?php endif; ?>
<?php endif; ?>
<div class="product-item-info <?= /* @escapeNotVerified */ $available ?>">
<?= /* @escapeNotVerified */ '<!-- ' . $image . '-->' ?>
<a href="<?= /* @escapeNotVerified */ $block->getProductUrl($_item) ?>" class="product photo product-item-photo">
<?= $block->getImage($_item, $image)->toHtml() ?>
</a>
<div class="product details product-item-details">
<strong class="product name product-item-name"><a class="product-item-link" title="<?= $block->escapeHtml($_item->getName()) ?>" href="<?= /* @escapeNotVerified */ $block->getProductUrl($_item) ?>">
<?= $block->escapeHtml($_item->getName()) ?></a>
</strong>
<?= /* @escapeNotVerified */ $block->getProductPrice($_item) ?>
<?php if ($templateType): ?>
<?= $block->getReviewsSummaryHtml($_item, $templateType) ?>
<?php endif; ?>
<?php if ($canItemsAddToCart && !$_item->isComposite() && $_item->isSaleable() && $type == 'related'): ?>
<?php if (!$_item->getRequiredOptions()): ?>
<div class="field choice related">
<input type="checkbox" class="checkbox related" id="related-checkbox<?= /* @escapeNotVerified */ $_item->getId() ?>" name="related_products[]" value="<?= /* @escapeNotVerified */ $_item->getId() ?>" />
<label class="label" for="related-checkbox<?= /* @escapeNotVerified */ $_item->getId() ?>"><span><?= /* @escapeNotVerified */ __('Add to Cart') ?></span></label>
</div>
<?php endif; ?>
<?php endif; ?>
<?php if ($showAddTo || $showCart): ?>
<div class="product actions product-item-actions">
<?php if ($showCart): ?>
<div class="actions-primary">
<?php if ($_item->isSaleable()): ?>
<?php if ($_item->getTypeInstance()->hasRequiredOptions($_item)): ?>
<button class="action tocart primary" data-mage-init='"redirectUrl": "url": "<?= /* @escapeNotVerified */ $block->getAddToCartUrl($_item) ?>"' type="button" title="<?= /* @escapeNotVerified */ __('Add to Cart') ?>">
<span><?= /* @escapeNotVerified */ __('Add to Cart') ?></span>
</button>
<?php else: ?>
<?php $postDataHelper = $this->helper('MagentoFrameworkDataHelperPostHelper');
$postData = $postDataHelper->getPostData($block->getAddToCartUrl($_item), ['product' => $_item->getEntityId()])
?>
<button class="action tocart primary"
data-post='<?= /* @escapeNotVerified */ $postData ?>'
type="button" title="<?= /* @escapeNotVerified */ __('Add to Cart') ?>">
<span><?= /* @escapeNotVerified */ __('Add to Cart') ?></span>
</button>
<?php endif; ?>
<?php else: ?>
<?php if ($_item->getIsSalable()): ?>
<div class="stock available"><span><?= /* @escapeNotVerified */ __('In stock') ?></span></div>
<?php else: ?>
<div class="stock unavailable"><span><?= /* @escapeNotVerified */ __('Out of stock') ?></span></div>
<?php endif; ?>
<?php endif; ?>
</div>
<?php endif; ?>
<?php if ($showAddTo): ?>
<div class="secondary-addto-links actions-secondary" data-role="add-to-links">
<?php if ($addToBlock = $block->getChildBlock('addto')): ?>
<?= $addToBlock->setProduct($_item)->getChildHtml() ?>
<?php endif; ?>
</div>
<?php endif; ?>
</div>
<?php endif; ?>
</div>
</div>
<?= ($iterator == count($items)+1) ? '</li>' : '' ?>
<?php endforeach ?>
</ol>
</div>
</div>
</div>
<?php
$type = 'upsell';
$class = $type;
$image = 'upsell_products_list';
$title = __('We found other products you might like!');
$items = $block->getUpsellProducts();
$limit = $block->getItemLimit('upsell');
$shuffle = 0;
$showAddTo = false;
$showCart = false;
$templateType = null;
$description = false;
$canItemsAddToCart = false;
?>
<h2><?php echo $title; ?></h2>
<div class="products wrapper">
<div class="products list items product-items">
<?php $iterator = 1; ?>
<?php foreach ($items as $_item): ?>
<?php $available = ''; ?>
<div class="product-item-info>
<?= /* @escapeNotVerified */ '<!-- ' . $image . '-->' ?>
<a href="<?= /* @escapeNotVerified */ $block->getProductUrl($_item) ?>" class="product photo product-item-photo">
<?= $block->getImage($_item, $image)->toHtml() ?>
</a>
<div class="product details product-item-details">
<strong class="product name product-item-name"><a class="product-item-link" title="<?= $block->escapeHtml($_item->getName()) ?>" href="<?= /* @escapeNotVerified */ $block->getProductUrl($_item) ?>">
<?= $block->escapeHtml($_item->getName()) ?></a>
</strong>
<?= /* @escapeNotVerified */ $block->getProductPrice($_item) ?>
<?php if ($templateType): ?>
<?= $block->getReviewsSummaryHtml($_item, $templateType) ?>
<?php endif; ?>
<?php if ($canItemsAddToCart && !$_item->isComposite() && $_item->isSaleable() && $type == 'related'): ?>
<?php if (!$_item->getRequiredOptions()): ?>
<div class="field choice related">
<input type="checkbox" class="checkbox related" id="related-checkbox<?= /* @escapeNotVerified */ $_item->getId() ?>" name="related_products[]" value="<?= /* @escapeNotVerified */ $_item->getId() ?>" />
<label class="label" for="related-checkbox<?= /* @escapeNotVerified */ $_item->getId() ?>"><span><?= /* @escapeNotVerified */ __('Add to Cart') ?></span></label>
</div>
<?php endif; ?>
<?php endif; ?>
<?php if ($showAddTo || $showCart): ?>
<div class="product actions product-item-actions">
<?php if ($showCart): ?>
<div class="actions-primary">
<?php if ($_item->isSaleable()): ?>
<?php if ($_item->getTypeInstance()->hasRequiredOptions($_item)): ?>
<button class="action tocart primary" data-mage-init='"redirectUrl": "url": "<?= /* @escapeNotVerified */ $block->getAddToCartUrl($_item) ?>"' type="button" title="<?= /* @escapeNotVerified */ __('Add to Cart') ?>">
<span><?= /* @escapeNotVerified */ __('Add to Cart') ?></span>
</button>
<?php else: ?>
<?php $postDataHelper = $this->helper('MagentoFrameworkDataHelperPostHelper');
$postData = $postDataHelper->getPostData($block->getAddToCartUrl($_item), ['product' => $_item->getEntityId()])
?>
<button class="action tocart primary"
data-post='<?= /* @escapeNotVerified */ $postData ?>'
type="button" title="<?= /* @escapeNotVerified */ __('Add to Cart') ?>">
<span><?= /* @escapeNotVerified */ __('Add to Cart') ?></span>
</button>
<?php endif; ?>
<?php else: ?>
<?php if ($_item->getIsSalable()): ?>
<div class="stock available"><span><?= /* @escapeNotVerified */ __('In stock') ?></span></div>
<?php else: ?>
<div class="stock unavailable"><span><?= /* @escapeNotVerified */ __('Out of stock') ?></span></div>
<?php endif; ?>
<?php endif; ?>
</div>
<?php endif; ?>
<?php if ($showAddTo): ?>
<div class="secondary-addto-links actions-secondary" data-role="add-to-links">
<?php if ($addToBlock = $block->getChildBlock('addto')): ?>
<?= $addToBlock->setProduct($_item)->getChildHtml() ?>
<?php endif; ?>
</div>
<?php endif; ?>
</div>
<?php endif; ?>
</div>
</div>
</div>
<?php endforeach ?>
</div>
</div>
Note: Please change PHTML pages code as per your design needs.
step 3: Run the following commands from your Magento root and check the product details page
sudo php bin/magento setup:di:compile
sudo php bin/magento cache:flush
Thanks @Pritam it worked
– Xain Ijaz
2 days ago
Welcome @XainIjaz
– Pritam Info 24
2 days ago
add a comment |
You may try the steps below.
Assume you are using a custom module (if not please create a custom module) named "Company_MyModule".
step 1) Create a block class MycrossUpsell.php under /app/code/Company/MyModule/Block
FIle:/app/code/Company/MyModule/Block/MycrossUpsell.php
<?php
namespace CompanyMyModuleBlock;
class MycrossUpsell extends MagentoCatalogBlockProductAbstractProduct implements MagentoFrameworkDataObjectIdentityInterface
/**
* @var Collection
*/
protected $_itemCollection;
/**
* Checkout session
*
* @var MagentoCheckoutModelSession
*/
protected $_checkoutSession;
/**
* Catalog product visibility
*
* @var MagentoCatalogModelProductVisibility
*/
protected $_catalogProductVisibility;
/**
* Checkout cart
*
* @var MagentoCheckoutModelResourceModelCart
*/
protected $_checkoutCart;
/**
* @var MagentoFrameworkModuleManager
*/
protected $moduleManager;
protected $_registry;
/**
* @param MagentoCatalogBlockProductContext $context
* @param MagentoCheckoutModelResourceModelCart $checkoutCart
* @param MagentoCatalogModelProductVisibility $catalogProductVisibility
* @param MagentoCheckoutModelSession $checkoutSession
* @param MagentoFrameworkModuleManager $moduleManager
* @param array $data
*/
public function __construct(
MagentoCatalogBlockProductContext $context,
MagentoCheckoutModelResourceModelCart $checkoutCart,
MagentoCatalogModelProductVisibility $catalogProductVisibility,
MagentoCheckoutModelSession $checkoutSession,
MagentoFrameworkModuleManager $moduleManager,
MagentoFrameworkRegistry $registry,
array $data = []
)
$this->_checkoutCart = $checkoutCart;
$this->_catalogProductVisibility = $catalogProductVisibility;
$this->_checkoutSession = $checkoutSession;
$this->moduleManager = $moduleManager;
$this->_registry = $registry;
parent::__construct(
$context,
$data
);
public function getCurrentProduct()
return $this->_registry->registry('current_product');
public function getRelatedProducts()
$product = $this->_coreRegistry->registry('product');
/* @var $product MagentoCatalogModelProduct */
$this->_itemCollection = $product->getRelatedProductCollection()->addAttributeToSelect(
'required_options'
)->setPositionOrder()->addStoreFilter();
if ($this->moduleManager->isEnabled('Magento_Checkout'))
$this->_addProductAttributesAndPrices($this->_itemCollection);
$this->_itemCollection->setVisibility($this->_catalogProductVisibility->getVisibleInCatalogIds());
$this->_itemCollection->load();
foreach ($this->_itemCollection as $product)
$product->setDoNotUseCategoryId(true);
return $this->_itemCollection;
public function getUpsellProducts()
$product = $this->_coreRegistry->registry('product');
/* @var $product MagentoCatalogModelProduct */
$this->_itemCollection = $product->getUpSellProductCollection()->addAttributeToSelect(
'required_options'
)->setPositionOrder()->addStoreFilter();
if ($this->moduleManager->isEnabled('Magento_Checkout'))
$this->_addProductAttributesAndPrices($this->_itemCollection);
$this->_itemCollection->setVisibility($this->_catalogProductVisibility->getVisibleInCatalogIds());
$this->_itemCollection->load();
foreach ($this->_itemCollection as $product)
$product->setDoNotUseCategoryId(true);
return $this->_itemCollection;
/**
* @return Collection
*/
public function getItems()
/**
* getIdentities() depends on _itemCollection populated, but it can be empty if the block is hidden
* @see https://github.com/magento/magento2/issues/5897
*/
if ($this->_itemCollection === null)
$this->_prepareData();
return $this->_itemCollection;
/**
* Return identifiers for produced content
*
* @return array
*/
public function getIdentities()
$identities = [];
foreach ($this->getItems() as $item)
$identities = array_merge($identities, $item->getIdentities());
return $identities;
/**
* Find out if some products can be easy added to cart
*
* @return bool
*/
public function canItemsAddToCart()
foreach ($this->getItems() as $item)
if (!$item->isComposite() && $item->isSaleable() && !$item->getRequiredOptions())
return true;
return false;
?>
step 2 : Create phtml file cross_upsell.phtml under /app/code/Company/MyModule/view/frontend/templates/product/view
File : /app/code/Company/MyModule/view/frontend/templates/product/view/cross_upsell.phtml
<?php
$type = 'related';
$class = $type;
$image = 'related_products_list';
$title = __('Related Products');
$items = $block->getRelatedProducts(); //$block->getAllItems();
$limit = $block->getPositionLimit();
$shuffle = 0;//(int) $block->isShuffled();
$canItemsAddToCart = $block->canItemsAddToCart();
$showAddTo = true;
$showCart = false;
$templateType = null;
$description = false;
?>
<h2><?php echo $title; ?></h2>
<div class="block-title title">
<strong id="block-<?= /* @escapeNotVerified */ $class ?>-heading" role="heading" aria-level="2"><?= /* @escapeNotVerified */ $title ?></strong>
</div>
<div class="block-content content" aria-labelledby="block-<?= /* @escapeNotVerified */ $class ?>-heading">
<div class="products wrapper grid products-grid products-<?= /* @escapeNotVerified */ $type ?>">
<ol class="products list items product-items">
<?php $iterator = 1; ?>
<?php foreach ($items as $_item): ?>
<?php $available = ''; ?>
<?php if (!$_item->isComposite() && $_item->isSaleable() && $type == 'related'): ?>
<?php if (!$_item->getRequiredOptions()): ?>
<?php $available = 'related-available'; ?>
<?php endif; ?>
<?php endif; ?>
<div class="product-item-info <?= /* @escapeNotVerified */ $available ?>">
<?= /* @escapeNotVerified */ '<!-- ' . $image . '-->' ?>
<a href="<?= /* @escapeNotVerified */ $block->getProductUrl($_item) ?>" class="product photo product-item-photo">
<?= $block->getImage($_item, $image)->toHtml() ?>
</a>
<div class="product details product-item-details">
<strong class="product name product-item-name"><a class="product-item-link" title="<?= $block->escapeHtml($_item->getName()) ?>" href="<?= /* @escapeNotVerified */ $block->getProductUrl($_item) ?>">
<?= $block->escapeHtml($_item->getName()) ?></a>
</strong>
<?= /* @escapeNotVerified */ $block->getProductPrice($_item) ?>
<?php if ($templateType): ?>
<?= $block->getReviewsSummaryHtml($_item, $templateType) ?>
<?php endif; ?>
<?php if ($canItemsAddToCart && !$_item->isComposite() && $_item->isSaleable() && $type == 'related'): ?>
<?php if (!$_item->getRequiredOptions()): ?>
<div class="field choice related">
<input type="checkbox" class="checkbox related" id="related-checkbox<?= /* @escapeNotVerified */ $_item->getId() ?>" name="related_products[]" value="<?= /* @escapeNotVerified */ $_item->getId() ?>" />
<label class="label" for="related-checkbox<?= /* @escapeNotVerified */ $_item->getId() ?>"><span><?= /* @escapeNotVerified */ __('Add to Cart') ?></span></label>
</div>
<?php endif; ?>
<?php endif; ?>
<?php if ($showAddTo || $showCart): ?>
<div class="product actions product-item-actions">
<?php if ($showCart): ?>
<div class="actions-primary">
<?php if ($_item->isSaleable()): ?>
<?php if ($_item->getTypeInstance()->hasRequiredOptions($_item)): ?>
<button class="action tocart primary" data-mage-init='"redirectUrl": "url": "<?= /* @escapeNotVerified */ $block->getAddToCartUrl($_item) ?>"' type="button" title="<?= /* @escapeNotVerified */ __('Add to Cart') ?>">
<span><?= /* @escapeNotVerified */ __('Add to Cart') ?></span>
</button>
<?php else: ?>
<?php $postDataHelper = $this->helper('MagentoFrameworkDataHelperPostHelper');
$postData = $postDataHelper->getPostData($block->getAddToCartUrl($_item), ['product' => $_item->getEntityId()])
?>
<button class="action tocart primary"
data-post='<?= /* @escapeNotVerified */ $postData ?>'
type="button" title="<?= /* @escapeNotVerified */ __('Add to Cart') ?>">
<span><?= /* @escapeNotVerified */ __('Add to Cart') ?></span>
</button>
<?php endif; ?>
<?php else: ?>
<?php if ($_item->getIsSalable()): ?>
<div class="stock available"><span><?= /* @escapeNotVerified */ __('In stock') ?></span></div>
<?php else: ?>
<div class="stock unavailable"><span><?= /* @escapeNotVerified */ __('Out of stock') ?></span></div>
<?php endif; ?>
<?php endif; ?>
</div>
<?php endif; ?>
<?php if ($showAddTo): ?>
<div class="secondary-addto-links actions-secondary" data-role="add-to-links">
<?php if ($addToBlock = $block->getChildBlock('addto')): ?>
<?= $addToBlock->setProduct($_item)->getChildHtml() ?>
<?php endif; ?>
</div>
<?php endif; ?>
</div>
<?php endif; ?>
</div>
</div>
<?= ($iterator == count($items)+1) ? '</li>' : '' ?>
<?php endforeach ?>
</ol>
</div>
</div>
</div>
<?php
$type = 'upsell';
$class = $type;
$image = 'upsell_products_list';
$title = __('We found other products you might like!');
$items = $block->getUpsellProducts();
$limit = $block->getItemLimit('upsell');
$shuffle = 0;
$showAddTo = false;
$showCart = false;
$templateType = null;
$description = false;
$canItemsAddToCart = false;
?>
<h2><?php echo $title; ?></h2>
<div class="products wrapper">
<div class="products list items product-items">
<?php $iterator = 1; ?>
<?php foreach ($items as $_item): ?>
<?php $available = ''; ?>
<div class="product-item-info>
<?= /* @escapeNotVerified */ '<!-- ' . $image . '-->' ?>
<a href="<?= /* @escapeNotVerified */ $block->getProductUrl($_item) ?>" class="product photo product-item-photo">
<?= $block->getImage($_item, $image)->toHtml() ?>
</a>
<div class="product details product-item-details">
<strong class="product name product-item-name"><a class="product-item-link" title="<?= $block->escapeHtml($_item->getName()) ?>" href="<?= /* @escapeNotVerified */ $block->getProductUrl($_item) ?>">
<?= $block->escapeHtml($_item->getName()) ?></a>
</strong>
<?= /* @escapeNotVerified */ $block->getProductPrice($_item) ?>
<?php if ($templateType): ?>
<?= $block->getReviewsSummaryHtml($_item, $templateType) ?>
<?php endif; ?>
<?php if ($canItemsAddToCart && !$_item->isComposite() && $_item->isSaleable() && $type == 'related'): ?>
<?php if (!$_item->getRequiredOptions()): ?>
<div class="field choice related">
<input type="checkbox" class="checkbox related" id="related-checkbox<?= /* @escapeNotVerified */ $_item->getId() ?>" name="related_products[]" value="<?= /* @escapeNotVerified */ $_item->getId() ?>" />
<label class="label" for="related-checkbox<?= /* @escapeNotVerified */ $_item->getId() ?>"><span><?= /* @escapeNotVerified */ __('Add to Cart') ?></span></label>
</div>
<?php endif; ?>
<?php endif; ?>
<?php if ($showAddTo || $showCart): ?>
<div class="product actions product-item-actions">
<?php if ($showCart): ?>
<div class="actions-primary">
<?php if ($_item->isSaleable()): ?>
<?php if ($_item->getTypeInstance()->hasRequiredOptions($_item)): ?>
<button class="action tocart primary" data-mage-init='"redirectUrl": "url": "<?= /* @escapeNotVerified */ $block->getAddToCartUrl($_item) ?>"' type="button" title="<?= /* @escapeNotVerified */ __('Add to Cart') ?>">
<span><?= /* @escapeNotVerified */ __('Add to Cart') ?></span>
</button>
<?php else: ?>
<?php $postDataHelper = $this->helper('MagentoFrameworkDataHelperPostHelper');
$postData = $postDataHelper->getPostData($block->getAddToCartUrl($_item), ['product' => $_item->getEntityId()])
?>
<button class="action tocart primary"
data-post='<?= /* @escapeNotVerified */ $postData ?>'
type="button" title="<?= /* @escapeNotVerified */ __('Add to Cart') ?>">
<span><?= /* @escapeNotVerified */ __('Add to Cart') ?></span>
</button>
<?php endif; ?>
<?php else: ?>
<?php if ($_item->getIsSalable()): ?>
<div class="stock available"><span><?= /* @escapeNotVerified */ __('In stock') ?></span></div>
<?php else: ?>
<div class="stock unavailable"><span><?= /* @escapeNotVerified */ __('Out of stock') ?></span></div>
<?php endif; ?>
<?php endif; ?>
</div>
<?php endif; ?>
<?php if ($showAddTo): ?>
<div class="secondary-addto-links actions-secondary" data-role="add-to-links">
<?php if ($addToBlock = $block->getChildBlock('addto')): ?>
<?= $addToBlock->setProduct($_item)->getChildHtml() ?>
<?php endif; ?>
</div>
<?php endif; ?>
</div>
<?php endif; ?>
</div>
</div>
</div>
<?php endforeach ?>
</div>
</div>
Note: Please change PHTML pages code as per your design needs.
step 3: Run the following commands from your Magento root and check the product details page
sudo php bin/magento setup:di:compile
sudo php bin/magento cache:flush
Thanks @Pritam it worked
– Xain Ijaz
2 days ago
Welcome @XainIjaz
– Pritam Info 24
2 days ago
add a comment |
You may try the steps below.
Assume you are using a custom module (if not please create a custom module) named "Company_MyModule".
step 1) Create a block class MycrossUpsell.php under /app/code/Company/MyModule/Block
FIle:/app/code/Company/MyModule/Block/MycrossUpsell.php
<?php
namespace CompanyMyModuleBlock;
class MycrossUpsell extends MagentoCatalogBlockProductAbstractProduct implements MagentoFrameworkDataObjectIdentityInterface
/**
* @var Collection
*/
protected $_itemCollection;
/**
* Checkout session
*
* @var MagentoCheckoutModelSession
*/
protected $_checkoutSession;
/**
* Catalog product visibility
*
* @var MagentoCatalogModelProductVisibility
*/
protected $_catalogProductVisibility;
/**
* Checkout cart
*
* @var MagentoCheckoutModelResourceModelCart
*/
protected $_checkoutCart;
/**
* @var MagentoFrameworkModuleManager
*/
protected $moduleManager;
protected $_registry;
/**
* @param MagentoCatalogBlockProductContext $context
* @param MagentoCheckoutModelResourceModelCart $checkoutCart
* @param MagentoCatalogModelProductVisibility $catalogProductVisibility
* @param MagentoCheckoutModelSession $checkoutSession
* @param MagentoFrameworkModuleManager $moduleManager
* @param array $data
*/
public function __construct(
MagentoCatalogBlockProductContext $context,
MagentoCheckoutModelResourceModelCart $checkoutCart,
MagentoCatalogModelProductVisibility $catalogProductVisibility,
MagentoCheckoutModelSession $checkoutSession,
MagentoFrameworkModuleManager $moduleManager,
MagentoFrameworkRegistry $registry,
array $data = []
)
$this->_checkoutCart = $checkoutCart;
$this->_catalogProductVisibility = $catalogProductVisibility;
$this->_checkoutSession = $checkoutSession;
$this->moduleManager = $moduleManager;
$this->_registry = $registry;
parent::__construct(
$context,
$data
);
public function getCurrentProduct()
return $this->_registry->registry('current_product');
public function getRelatedProducts()
$product = $this->_coreRegistry->registry('product');
/* @var $product MagentoCatalogModelProduct */
$this->_itemCollection = $product->getRelatedProductCollection()->addAttributeToSelect(
'required_options'
)->setPositionOrder()->addStoreFilter();
if ($this->moduleManager->isEnabled('Magento_Checkout'))
$this->_addProductAttributesAndPrices($this->_itemCollection);
$this->_itemCollection->setVisibility($this->_catalogProductVisibility->getVisibleInCatalogIds());
$this->_itemCollection->load();
foreach ($this->_itemCollection as $product)
$product->setDoNotUseCategoryId(true);
return $this->_itemCollection;
public function getUpsellProducts()
$product = $this->_coreRegistry->registry('product');
/* @var $product MagentoCatalogModelProduct */
$this->_itemCollection = $product->getUpSellProductCollection()->addAttributeToSelect(
'required_options'
)->setPositionOrder()->addStoreFilter();
if ($this->moduleManager->isEnabled('Magento_Checkout'))
$this->_addProductAttributesAndPrices($this->_itemCollection);
$this->_itemCollection->setVisibility($this->_catalogProductVisibility->getVisibleInCatalogIds());
$this->_itemCollection->load();
foreach ($this->_itemCollection as $product)
$product->setDoNotUseCategoryId(true);
return $this->_itemCollection;
/**
* @return Collection
*/
public function getItems()
/**
* getIdentities() depends on _itemCollection populated, but it can be empty if the block is hidden
* @see https://github.com/magento/magento2/issues/5897
*/
if ($this->_itemCollection === null)
$this->_prepareData();
return $this->_itemCollection;
/**
* Return identifiers for produced content
*
* @return array
*/
public function getIdentities()
$identities = [];
foreach ($this->getItems() as $item)
$identities = array_merge($identities, $item->getIdentities());
return $identities;
/**
* Find out if some products can be easy added to cart
*
* @return bool
*/
public function canItemsAddToCart()
foreach ($this->getItems() as $item)
if (!$item->isComposite() && $item->isSaleable() && !$item->getRequiredOptions())
return true;
return false;
?>
step 2 : Create phtml file cross_upsell.phtml under /app/code/Company/MyModule/view/frontend/templates/product/view
File : /app/code/Company/MyModule/view/frontend/templates/product/view/cross_upsell.phtml
<?php
$type = 'related';
$class = $type;
$image = 'related_products_list';
$title = __('Related Products');
$items = $block->getRelatedProducts(); //$block->getAllItems();
$limit = $block->getPositionLimit();
$shuffle = 0;//(int) $block->isShuffled();
$canItemsAddToCart = $block->canItemsAddToCart();
$showAddTo = true;
$showCart = false;
$templateType = null;
$description = false;
?>
<h2><?php echo $title; ?></h2>
<div class="block-title title">
<strong id="block-<?= /* @escapeNotVerified */ $class ?>-heading" role="heading" aria-level="2"><?= /* @escapeNotVerified */ $title ?></strong>
</div>
<div class="block-content content" aria-labelledby="block-<?= /* @escapeNotVerified */ $class ?>-heading">
<div class="products wrapper grid products-grid products-<?= /* @escapeNotVerified */ $type ?>">
<ol class="products list items product-items">
<?php $iterator = 1; ?>
<?php foreach ($items as $_item): ?>
<?php $available = ''; ?>
<?php if (!$_item->isComposite() && $_item->isSaleable() && $type == 'related'): ?>
<?php if (!$_item->getRequiredOptions()): ?>
<?php $available = 'related-available'; ?>
<?php endif; ?>
<?php endif; ?>
<div class="product-item-info <?= /* @escapeNotVerified */ $available ?>">
<?= /* @escapeNotVerified */ '<!-- ' . $image . '-->' ?>
<a href="<?= /* @escapeNotVerified */ $block->getProductUrl($_item) ?>" class="product photo product-item-photo">
<?= $block->getImage($_item, $image)->toHtml() ?>
</a>
<div class="product details product-item-details">
<strong class="product name product-item-name"><a class="product-item-link" title="<?= $block->escapeHtml($_item->getName()) ?>" href="<?= /* @escapeNotVerified */ $block->getProductUrl($_item) ?>">
<?= $block->escapeHtml($_item->getName()) ?></a>
</strong>
<?= /* @escapeNotVerified */ $block->getProductPrice($_item) ?>
<?php if ($templateType): ?>
<?= $block->getReviewsSummaryHtml($_item, $templateType) ?>
<?php endif; ?>
<?php if ($canItemsAddToCart && !$_item->isComposite() && $_item->isSaleable() && $type == 'related'): ?>
<?php if (!$_item->getRequiredOptions()): ?>
<div class="field choice related">
<input type="checkbox" class="checkbox related" id="related-checkbox<?= /* @escapeNotVerified */ $_item->getId() ?>" name="related_products[]" value="<?= /* @escapeNotVerified */ $_item->getId() ?>" />
<label class="label" for="related-checkbox<?= /* @escapeNotVerified */ $_item->getId() ?>"><span><?= /* @escapeNotVerified */ __('Add to Cart') ?></span></label>
</div>
<?php endif; ?>
<?php endif; ?>
<?php if ($showAddTo || $showCart): ?>
<div class="product actions product-item-actions">
<?php if ($showCart): ?>
<div class="actions-primary">
<?php if ($_item->isSaleable()): ?>
<?php if ($_item->getTypeInstance()->hasRequiredOptions($_item)): ?>
<button class="action tocart primary" data-mage-init='"redirectUrl": "url": "<?= /* @escapeNotVerified */ $block->getAddToCartUrl($_item) ?>"' type="button" title="<?= /* @escapeNotVerified */ __('Add to Cart') ?>">
<span><?= /* @escapeNotVerified */ __('Add to Cart') ?></span>
</button>
<?php else: ?>
<?php $postDataHelper = $this->helper('MagentoFrameworkDataHelperPostHelper');
$postData = $postDataHelper->getPostData($block->getAddToCartUrl($_item), ['product' => $_item->getEntityId()])
?>
<button class="action tocart primary"
data-post='<?= /* @escapeNotVerified */ $postData ?>'
type="button" title="<?= /* @escapeNotVerified */ __('Add to Cart') ?>">
<span><?= /* @escapeNotVerified */ __('Add to Cart') ?></span>
</button>
<?php endif; ?>
<?php else: ?>
<?php if ($_item->getIsSalable()): ?>
<div class="stock available"><span><?= /* @escapeNotVerified */ __('In stock') ?></span></div>
<?php else: ?>
<div class="stock unavailable"><span><?= /* @escapeNotVerified */ __('Out of stock') ?></span></div>
<?php endif; ?>
<?php endif; ?>
</div>
<?php endif; ?>
<?php if ($showAddTo): ?>
<div class="secondary-addto-links actions-secondary" data-role="add-to-links">
<?php if ($addToBlock = $block->getChildBlock('addto')): ?>
<?= $addToBlock->setProduct($_item)->getChildHtml() ?>
<?php endif; ?>
</div>
<?php endif; ?>
</div>
<?php endif; ?>
</div>
</div>
<?= ($iterator == count($items)+1) ? '</li>' : '' ?>
<?php endforeach ?>
</ol>
</div>
</div>
</div>
<?php
$type = 'upsell';
$class = $type;
$image = 'upsell_products_list';
$title = __('We found other products you might like!');
$items = $block->getUpsellProducts();
$limit = $block->getItemLimit('upsell');
$shuffle = 0;
$showAddTo = false;
$showCart = false;
$templateType = null;
$description = false;
$canItemsAddToCart = false;
?>
<h2><?php echo $title; ?></h2>
<div class="products wrapper">
<div class="products list items product-items">
<?php $iterator = 1; ?>
<?php foreach ($items as $_item): ?>
<?php $available = ''; ?>
<div class="product-item-info>
<?= /* @escapeNotVerified */ '<!-- ' . $image . '-->' ?>
<a href="<?= /* @escapeNotVerified */ $block->getProductUrl($_item) ?>" class="product photo product-item-photo">
<?= $block->getImage($_item, $image)->toHtml() ?>
</a>
<div class="product details product-item-details">
<strong class="product name product-item-name"><a class="product-item-link" title="<?= $block->escapeHtml($_item->getName()) ?>" href="<?= /* @escapeNotVerified */ $block->getProductUrl($_item) ?>">
<?= $block->escapeHtml($_item->getName()) ?></a>
</strong>
<?= /* @escapeNotVerified */ $block->getProductPrice($_item) ?>
<?php if ($templateType): ?>
<?= $block->getReviewsSummaryHtml($_item, $templateType) ?>
<?php endif; ?>
<?php if ($canItemsAddToCart && !$_item->isComposite() && $_item->isSaleable() && $type == 'related'): ?>
<?php if (!$_item->getRequiredOptions()): ?>
<div class="field choice related">
<input type="checkbox" class="checkbox related" id="related-checkbox<?= /* @escapeNotVerified */ $_item->getId() ?>" name="related_products[]" value="<?= /* @escapeNotVerified */ $_item->getId() ?>" />
<label class="label" for="related-checkbox<?= /* @escapeNotVerified */ $_item->getId() ?>"><span><?= /* @escapeNotVerified */ __('Add to Cart') ?></span></label>
</div>
<?php endif; ?>
<?php endif; ?>
<?php if ($showAddTo || $showCart): ?>
<div class="product actions product-item-actions">
<?php if ($showCart): ?>
<div class="actions-primary">
<?php if ($_item->isSaleable()): ?>
<?php if ($_item->getTypeInstance()->hasRequiredOptions($_item)): ?>
<button class="action tocart primary" data-mage-init='"redirectUrl": "url": "<?= /* @escapeNotVerified */ $block->getAddToCartUrl($_item) ?>"' type="button" title="<?= /* @escapeNotVerified */ __('Add to Cart') ?>">
<span><?= /* @escapeNotVerified */ __('Add to Cart') ?></span>
</button>
<?php else: ?>
<?php $postDataHelper = $this->helper('MagentoFrameworkDataHelperPostHelper');
$postData = $postDataHelper->getPostData($block->getAddToCartUrl($_item), ['product' => $_item->getEntityId()])
?>
<button class="action tocart primary"
data-post='<?= /* @escapeNotVerified */ $postData ?>'
type="button" title="<?= /* @escapeNotVerified */ __('Add to Cart') ?>">
<span><?= /* @escapeNotVerified */ __('Add to Cart') ?></span>
</button>
<?php endif; ?>
<?php else: ?>
<?php if ($_item->getIsSalable()): ?>
<div class="stock available"><span><?= /* @escapeNotVerified */ __('In stock') ?></span></div>
<?php else: ?>
<div class="stock unavailable"><span><?= /* @escapeNotVerified */ __('Out of stock') ?></span></div>
<?php endif; ?>
<?php endif; ?>
</div>
<?php endif; ?>
<?php if ($showAddTo): ?>
<div class="secondary-addto-links actions-secondary" data-role="add-to-links">
<?php if ($addToBlock = $block->getChildBlock('addto')): ?>
<?= $addToBlock->setProduct($_item)->getChildHtml() ?>
<?php endif; ?>
</div>
<?php endif; ?>
</div>
<?php endif; ?>
</div>
</div>
</div>
<?php endforeach ?>
</div>
</div>
Note: Please change PHTML pages code as per your design needs.
step 3: Run the following commands from your Magento root and check the product details page
sudo php bin/magento setup:di:compile
sudo php bin/magento cache:flush
You may try the steps below.
Assume you are using a custom module (if not please create a custom module) named "Company_MyModule".
step 1) Create a block class MycrossUpsell.php under /app/code/Company/MyModule/Block
FIle:/app/code/Company/MyModule/Block/MycrossUpsell.php
<?php
namespace CompanyMyModuleBlock;
class MycrossUpsell extends MagentoCatalogBlockProductAbstractProduct implements MagentoFrameworkDataObjectIdentityInterface
/**
* @var Collection
*/
protected $_itemCollection;
/**
* Checkout session
*
* @var MagentoCheckoutModelSession
*/
protected $_checkoutSession;
/**
* Catalog product visibility
*
* @var MagentoCatalogModelProductVisibility
*/
protected $_catalogProductVisibility;
/**
* Checkout cart
*
* @var MagentoCheckoutModelResourceModelCart
*/
protected $_checkoutCart;
/**
* @var MagentoFrameworkModuleManager
*/
protected $moduleManager;
protected $_registry;
/**
* @param MagentoCatalogBlockProductContext $context
* @param MagentoCheckoutModelResourceModelCart $checkoutCart
* @param MagentoCatalogModelProductVisibility $catalogProductVisibility
* @param MagentoCheckoutModelSession $checkoutSession
* @param MagentoFrameworkModuleManager $moduleManager
* @param array $data
*/
public function __construct(
MagentoCatalogBlockProductContext $context,
MagentoCheckoutModelResourceModelCart $checkoutCart,
MagentoCatalogModelProductVisibility $catalogProductVisibility,
MagentoCheckoutModelSession $checkoutSession,
MagentoFrameworkModuleManager $moduleManager,
MagentoFrameworkRegistry $registry,
array $data = []
)
$this->_checkoutCart = $checkoutCart;
$this->_catalogProductVisibility = $catalogProductVisibility;
$this->_checkoutSession = $checkoutSession;
$this->moduleManager = $moduleManager;
$this->_registry = $registry;
parent::__construct(
$context,
$data
);
public function getCurrentProduct()
return $this->_registry->registry('current_product');
public function getRelatedProducts()
$product = $this->_coreRegistry->registry('product');
/* @var $product MagentoCatalogModelProduct */
$this->_itemCollection = $product->getRelatedProductCollection()->addAttributeToSelect(
'required_options'
)->setPositionOrder()->addStoreFilter();
if ($this->moduleManager->isEnabled('Magento_Checkout'))
$this->_addProductAttributesAndPrices($this->_itemCollection);
$this->_itemCollection->setVisibility($this->_catalogProductVisibility->getVisibleInCatalogIds());
$this->_itemCollection->load();
foreach ($this->_itemCollection as $product)
$product->setDoNotUseCategoryId(true);
return $this->_itemCollection;
public function getUpsellProducts()
$product = $this->_coreRegistry->registry('product');
/* @var $product MagentoCatalogModelProduct */
$this->_itemCollection = $product->getUpSellProductCollection()->addAttributeToSelect(
'required_options'
)->setPositionOrder()->addStoreFilter();
if ($this->moduleManager->isEnabled('Magento_Checkout'))
$this->_addProductAttributesAndPrices($this->_itemCollection);
$this->_itemCollection->setVisibility($this->_catalogProductVisibility->getVisibleInCatalogIds());
$this->_itemCollection->load();
foreach ($this->_itemCollection as $product)
$product->setDoNotUseCategoryId(true);
return $this->_itemCollection;
/**
* @return Collection
*/
public function getItems()
/**
* getIdentities() depends on _itemCollection populated, but it can be empty if the block is hidden
* @see https://github.com/magento/magento2/issues/5897
*/
if ($this->_itemCollection === null)
$this->_prepareData();
return $this->_itemCollection;
/**
* Return identifiers for produced content
*
* @return array
*/
public function getIdentities()
$identities = [];
foreach ($this->getItems() as $item)
$identities = array_merge($identities, $item->getIdentities());
return $identities;
/**
* Find out if some products can be easy added to cart
*
* @return bool
*/
public function canItemsAddToCart()
foreach ($this->getItems() as $item)
if (!$item->isComposite() && $item->isSaleable() && !$item->getRequiredOptions())
return true;
return false;
?>
step 2 : Create phtml file cross_upsell.phtml under /app/code/Company/MyModule/view/frontend/templates/product/view
File : /app/code/Company/MyModule/view/frontend/templates/product/view/cross_upsell.phtml
<?php
$type = 'related';
$class = $type;
$image = 'related_products_list';
$title = __('Related Products');
$items = $block->getRelatedProducts(); //$block->getAllItems();
$limit = $block->getPositionLimit();
$shuffle = 0;//(int) $block->isShuffled();
$canItemsAddToCart = $block->canItemsAddToCart();
$showAddTo = true;
$showCart = false;
$templateType = null;
$description = false;
?>
<h2><?php echo $title; ?></h2>
<div class="block-title title">
<strong id="block-<?= /* @escapeNotVerified */ $class ?>-heading" role="heading" aria-level="2"><?= /* @escapeNotVerified */ $title ?></strong>
</div>
<div class="block-content content" aria-labelledby="block-<?= /* @escapeNotVerified */ $class ?>-heading">
<div class="products wrapper grid products-grid products-<?= /* @escapeNotVerified */ $type ?>">
<ol class="products list items product-items">
<?php $iterator = 1; ?>
<?php foreach ($items as $_item): ?>
<?php $available = ''; ?>
<?php if (!$_item->isComposite() && $_item->isSaleable() && $type == 'related'): ?>
<?php if (!$_item->getRequiredOptions()): ?>
<?php $available = 'related-available'; ?>
<?php endif; ?>
<?php endif; ?>
<div class="product-item-info <?= /* @escapeNotVerified */ $available ?>">
<?= /* @escapeNotVerified */ '<!-- ' . $image . '-->' ?>
<a href="<?= /* @escapeNotVerified */ $block->getProductUrl($_item) ?>" class="product photo product-item-photo">
<?= $block->getImage($_item, $image)->toHtml() ?>
</a>
<div class="product details product-item-details">
<strong class="product name product-item-name"><a class="product-item-link" title="<?= $block->escapeHtml($_item->getName()) ?>" href="<?= /* @escapeNotVerified */ $block->getProductUrl($_item) ?>">
<?= $block->escapeHtml($_item->getName()) ?></a>
</strong>
<?= /* @escapeNotVerified */ $block->getProductPrice($_item) ?>
<?php if ($templateType): ?>
<?= $block->getReviewsSummaryHtml($_item, $templateType) ?>
<?php endif; ?>
<?php if ($canItemsAddToCart && !$_item->isComposite() && $_item->isSaleable() && $type == 'related'): ?>
<?php if (!$_item->getRequiredOptions()): ?>
<div class="field choice related">
<input type="checkbox" class="checkbox related" id="related-checkbox<?= /* @escapeNotVerified */ $_item->getId() ?>" name="related_products[]" value="<?= /* @escapeNotVerified */ $_item->getId() ?>" />
<label class="label" for="related-checkbox<?= /* @escapeNotVerified */ $_item->getId() ?>"><span><?= /* @escapeNotVerified */ __('Add to Cart') ?></span></label>
</div>
<?php endif; ?>
<?php endif; ?>
<?php if ($showAddTo || $showCart): ?>
<div class="product actions product-item-actions">
<?php if ($showCart): ?>
<div class="actions-primary">
<?php if ($_item->isSaleable()): ?>
<?php if ($_item->getTypeInstance()->hasRequiredOptions($_item)): ?>
<button class="action tocart primary" data-mage-init='"redirectUrl": "url": "<?= /* @escapeNotVerified */ $block->getAddToCartUrl($_item) ?>"' type="button" title="<?= /* @escapeNotVerified */ __('Add to Cart') ?>">
<span><?= /* @escapeNotVerified */ __('Add to Cart') ?></span>
</button>
<?php else: ?>
<?php $postDataHelper = $this->helper('MagentoFrameworkDataHelperPostHelper');
$postData = $postDataHelper->getPostData($block->getAddToCartUrl($_item), ['product' => $_item->getEntityId()])
?>
<button class="action tocart primary"
data-post='<?= /* @escapeNotVerified */ $postData ?>'
type="button" title="<?= /* @escapeNotVerified */ __('Add to Cart') ?>">
<span><?= /* @escapeNotVerified */ __('Add to Cart') ?></span>
</button>
<?php endif; ?>
<?php else: ?>
<?php if ($_item->getIsSalable()): ?>
<div class="stock available"><span><?= /* @escapeNotVerified */ __('In stock') ?></span></div>
<?php else: ?>
<div class="stock unavailable"><span><?= /* @escapeNotVerified */ __('Out of stock') ?></span></div>
<?php endif; ?>
<?php endif; ?>
</div>
<?php endif; ?>
<?php if ($showAddTo): ?>
<div class="secondary-addto-links actions-secondary" data-role="add-to-links">
<?php if ($addToBlock = $block->getChildBlock('addto')): ?>
<?= $addToBlock->setProduct($_item)->getChildHtml() ?>
<?php endif; ?>
</div>
<?php endif; ?>
</div>
<?php endif; ?>
</div>
</div>
<?= ($iterator == count($items)+1) ? '</li>' : '' ?>
<?php endforeach ?>
</ol>
</div>
</div>
</div>
<?php
$type = 'upsell';
$class = $type;
$image = 'upsell_products_list';
$title = __('We found other products you might like!');
$items = $block->getUpsellProducts();
$limit = $block->getItemLimit('upsell');
$shuffle = 0;
$showAddTo = false;
$showCart = false;
$templateType = null;
$description = false;
$canItemsAddToCart = false;
?>
<h2><?php echo $title; ?></h2>
<div class="products wrapper">
<div class="products list items product-items">
<?php $iterator = 1; ?>
<?php foreach ($items as $_item): ?>
<?php $available = ''; ?>
<div class="product-item-info>
<?= /* @escapeNotVerified */ '<!-- ' . $image . '-->' ?>
<a href="<?= /* @escapeNotVerified */ $block->getProductUrl($_item) ?>" class="product photo product-item-photo">
<?= $block->getImage($_item, $image)->toHtml() ?>
</a>
<div class="product details product-item-details">
<strong class="product name product-item-name"><a class="product-item-link" title="<?= $block->escapeHtml($_item->getName()) ?>" href="<?= /* @escapeNotVerified */ $block->getProductUrl($_item) ?>">
<?= $block->escapeHtml($_item->getName()) ?></a>
</strong>
<?= /* @escapeNotVerified */ $block->getProductPrice($_item) ?>
<?php if ($templateType): ?>
<?= $block->getReviewsSummaryHtml($_item, $templateType) ?>
<?php endif; ?>
<?php if ($canItemsAddToCart && !$_item->isComposite() && $_item->isSaleable() && $type == 'related'): ?>
<?php if (!$_item->getRequiredOptions()): ?>
<div class="field choice related">
<input type="checkbox" class="checkbox related" id="related-checkbox<?= /* @escapeNotVerified */ $_item->getId() ?>" name="related_products[]" value="<?= /* @escapeNotVerified */ $_item->getId() ?>" />
<label class="label" for="related-checkbox<?= /* @escapeNotVerified */ $_item->getId() ?>"><span><?= /* @escapeNotVerified */ __('Add to Cart') ?></span></label>
</div>
<?php endif; ?>
<?php endif; ?>
<?php if ($showAddTo || $showCart): ?>
<div class="product actions product-item-actions">
<?php if ($showCart): ?>
<div class="actions-primary">
<?php if ($_item->isSaleable()): ?>
<?php if ($_item->getTypeInstance()->hasRequiredOptions($_item)): ?>
<button class="action tocart primary" data-mage-init='"redirectUrl": "url": "<?= /* @escapeNotVerified */ $block->getAddToCartUrl($_item) ?>"' type="button" title="<?= /* @escapeNotVerified */ __('Add to Cart') ?>">
<span><?= /* @escapeNotVerified */ __('Add to Cart') ?></span>
</button>
<?php else: ?>
<?php $postDataHelper = $this->helper('MagentoFrameworkDataHelperPostHelper');
$postData = $postDataHelper->getPostData($block->getAddToCartUrl($_item), ['product' => $_item->getEntityId()])
?>
<button class="action tocart primary"
data-post='<?= /* @escapeNotVerified */ $postData ?>'
type="button" title="<?= /* @escapeNotVerified */ __('Add to Cart') ?>">
<span><?= /* @escapeNotVerified */ __('Add to Cart') ?></span>
</button>
<?php endif; ?>
<?php else: ?>
<?php if ($_item->getIsSalable()): ?>
<div class="stock available"><span><?= /* @escapeNotVerified */ __('In stock') ?></span></div>
<?php else: ?>
<div class="stock unavailable"><span><?= /* @escapeNotVerified */ __('Out of stock') ?></span></div>
<?php endif; ?>
<?php endif; ?>
</div>
<?php endif; ?>
<?php if ($showAddTo): ?>
<div class="secondary-addto-links actions-secondary" data-role="add-to-links">
<?php if ($addToBlock = $block->getChildBlock('addto')): ?>
<?= $addToBlock->setProduct($_item)->getChildHtml() ?>
<?php endif; ?>
</div>
<?php endif; ?>
</div>
<?php endif; ?>
</div>
</div>
</div>
<?php endforeach ?>
</div>
</div>
Note: Please change PHTML pages code as per your design needs.
step 3: Run the following commands from your Magento root and check the product details page
sudo php bin/magento setup:di:compile
sudo php bin/magento cache:flush
answered 2 days ago
Pritam Info 24Pritam Info 24
84217
84217
Thanks @Pritam it worked
– Xain Ijaz
2 days ago
Welcome @XainIjaz
– Pritam Info 24
2 days ago
add a comment |
Thanks @Pritam it worked
– Xain Ijaz
2 days ago
Welcome @XainIjaz
– Pritam Info 24
2 days ago
Thanks @Pritam it worked
– Xain Ijaz
2 days ago
Thanks @Pritam it worked
– Xain Ijaz
2 days ago
Welcome @XainIjaz
– Pritam Info 24
2 days ago
Welcome @XainIjaz
– Pritam Info 24
2 days ago
add a comment |
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f270934%2fhow-to-show-both-at-same-time-upsell-and-related-products-in-product-view-page-m%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown