OK as a complete solution to this using @Dominic Ferrantelli initial answer and also the logic required to add the bundle product to the cart straight from the category page as well please see below:
@Dominic Ferrantelli Answer - Start
Magento_Bundle/layout/catalog_product_view_type_bundle.xml
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<move element="bundle.options.container" destination="product.info.main" after="product.info.price"/>
<container name="product.info.social.wrapper" />
<move element="product.info.social.wrapper" destination="product.info.main" after="bundle.options.container" />
<move element="product.info.social" destination="product.info.social.wrapper"/>
<referenceBlock name="customize.button" remove="true" />
</body>
</page>
@Dominic Ferrantelli Answer - End
@Dominic Ferrantelli answer removes all the unwanted bundle elements from the page but keeping the bundle wrapper which contains the bundle add to cart form.
My Extended answer - Start
instead of using @Dominic Ferrantelli styles you could use this .less instead
app/design/Vendor/ThemeName/web/css/source/_theme.less
.catalog-product-view {
.block-bundle-summary {
.title, .product-image-container, .product-details .product.name, .bundle-summary, .price, .available.stock {display:none;}
}
.bundle-options-wrapper {display:none;}
}
Now to add the bundle add to cart logic to the category you need to do the following:
Create a custom module (plenty of online documentation for this so I wont cover it here) and add the following:
Declare observer / method rewrite
app\code\Vendor\Module\etc\frontend\di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd">
<preference for="Magento\Catalog\Block\Product\ListProduct" type="Vendor\Module\Block\Frontend\CategoryCartParams" />
</config>
Rewrite the Magento\Catalog\Block\Product\ListProduct::getAddToCartPostParams() method with the following:
app\code\Vendor\Module\Block\Frontend\CategoryCartParams.php
<?php
namespace Vendor\Module\Block\Frontend;
use Magento\Catalog\Api\CategoryRepositoryInterface;
use Magento\Catalog\Model\Category;
use Magento\Catalog\Model\Product;
use Magento\Eav\Model\Entity\Collection\AbstractCollection;
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Framework\DataObject\IdentityInterface;
class CategoryCartParams extends \Magento\Catalog\Block\Product\ListProduct
{
/**
* Default toolbar block name
*
* @var string
*/
protected $_defaultToolbarBlock = 'Magento\Catalog\Block\Product\ProductList\Toolbar';
/**
* Product Collection
*
* @var AbstractCollection
*/
protected $_productCollection;
/**
* Catalog layer
*
* @var \Magento\Catalog\Model\Layer
*/
protected $_catalogLayer;
/**
* @var \Magento\Framework\Data\Helper\PostHelper
*/
protected $_postDataHelper;
/**
* @var \Magento\Framework\Url\Helper\Data
*/
protected $urlHelper;
/**
* @var CategoryRepositoryInterface
*/
protected $categoryRepository;
/**
* @param Context $context
* @param \Magento\Framework\Data\Helper\PostHelper $postDataHelper
* @param \Magento\Catalog\Model\Layer\Resolver $layerResolver
* @param CategoryRepositoryInterface $categoryRepository
* @param \Magento\Framework\Url\Helper\Data $urlHelper
* @param array $data
*/
public function __construct(
\Magento\Catalog\Block\Product\Context $context,
\Magento\Framework\Data\Helper\PostHelper $postDataHelper,
\Magento\Catalog\Model\Layer\Resolver $layerResolver,
CategoryRepositoryInterface $categoryRepository,
\Magento\Framework\Url\Helper\Data $urlHelper,
array $data = []
) {
parent::__construct($context, $postDataHelper, $layerResolver, $categoryRepository, $urlHelper, $data);
}
/**
* Get post parameters
*
* @param \Magento\Catalog\Model\Product $product
* @return string
*/
public function getAddToCartPostParams(\Magento\Catalog\Model\Product $product)
{
if ($product->getTypeId() == \Magento\Bundle\Model\Product\Type::TYPE_CODE)
{
$url = $this->getAddToCartUrl($product);
$selectionCollection = $product->getTypeInstance(true)
->getSelectionsCollection(
$product->getTypeInstance(true)->getOptionsIds($product),
$product
);
$bundleOptions = '?';
foreach($selectionCollection as $selection)
{
$bundleOptions .= '&bundle_option[' . $selection->getOptionId() . ']=' . $selection->getSelectionId();
$bundleOptions .= '&bundle_option_qty[' . $selection->getOptionId() . ']=' . $selection->getSelectionQty();
}
$url .= $bundleOptions;
return [
'action' => $url,
'data' => [
'product' => $product->getEntityId(),
\Magento\Framework\App\ActionInterface::PARAM_NAME_URL_ENCODED => $this->urlHelper->getEncodedUrl($url),
]
];
} else
{
$url = $this->getAddToCartUrl($product);
return [
'action' => $url,
'data' => [
'product' => $product->getEntityId(),
\Magento\Framework\App\ActionInterface::PARAM_NAME_URL_ENCODED =>
$this->urlHelper->getEncodedUrl($url),
]
];
}
}
}
This rewrite basically adds a query string of all the bundle options for the parent product and appends it to the add to cart url if a bundled product.
This is all tested and working as I needed to build this for my current project.