You can do it using xml for bulk products. for that you will have to override helper and create attribute for that. let me explain you descriptively.
Step 1: Create product attribute 'customlayout'.
- Create cutom product-attribute for custom layout, here I have just
created attribute 'customlayout' with type boolean(yes/no).
- Assign this attribute in appropriate attribute-set.
- Now 'customlayout' is visible in products , set yes in those products which you want to set different layout.
Step 2: Override Helper function initProductLayout().
Override above helper function in your custom module and also change in di.xml file to override helper.
app/code/YourCompany/YourModule/etc/di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<preference for="Magento\Catalog\Helper\Product\View" type="YourCompany\YourModule\Helper\Product\View" />
</config>
in YourCompany\YourModule\Helper\Product\view.php file.
public function initProductLayout(ResultPage $resultPage, $product, $params = null)
{
......
// add handle params
......
if ($params && $params->getBeforeHandles()) {
foreach ($params->getBeforeHandles() as $handle) {
$resultPage->addPageLayoutHandles(['customlayout' => $product->getCustomlayout(), 'id' => $product->getId(), 'sku' => $urlSafeSku], $handle);
$resultPage->addPageLayoutHandles(['type' => $product->getTypeId()], $handle, false);
}
}
$resultPage->addPageLayoutHandles(['customlayout' => $product->getCustomlayout(), 'id' => $product->getId(), 'sku' => $urlSafeSku]);
$resultPage->addPageLayoutHandles(['type' => $product->getTypeId()], null, false);
if ($params && $params->getAfterHandles()) {
foreach ($params->getAfterHandles() as $handle) {
$resultPage->addPageLayoutHandles(['customlayout' => $product->getCustomlayout(), 'id' => $product->getId(), 'sku' => $urlSafeSku], $handle);
$resultPage->addPageLayoutHandles(['type' => $product->getTypeId()], $handle, false);
}
}
........
}
Here I have added custom attribute for custom layout handle.
now you can create custom layout file to use this attribute.
let's create custom handle file.
Step 3: Create layout file for custom layout.
Create layout file in your custom theme/ custom module.
catalog_product_view_customlayout_1.xml
Here you can set your custom changes in it. it will be applied to all the products which have 'customlayout' attibute value is 'yes'.