Onclick Category Link , We have to display all Products ( Only if the Product attribute [ Ready to Ship ] value is "YES". )
We don't want to display Products in that url when the Product attribute value is No.
We are using PWA Magento 2.4.5 Venia Theme.
attribute code :
ready_to_ship
I am using below code, what mistake i am doing ?
vendor/magento/module-catalog/view/frontend/templates/category - products.phtml
<?php if (!$block->isContentMode() || $block->isMixedMode()) :?>
<?= $block->getProductListHtml() ?>
<?php endif; ?>
<?php
$objectManager = \Magento\Framework\App\objectManager::getInstance();
$product = $objectManager->create('Magento\Catalog\Model\Product')->load($singleproductdata['entity_id']);
$attributes = $product->getAttributes('ready_to_ship');
foreach ($attributes as $attribute) {
echo $attribute->getAttributeCode();
echo $attribute->getFrontend()->getValue($product);
}
?>