I am getting error with Magento 2.4.4 & 2.4.5
Here is my line of code
<?php echo strpos($pos, $viewMode . '-primary') ? $position : ''; ?>>
In Magento 2.4.4 was changed some important logic in vendor/magento/module-catalog/view/frontend/templates/product/list.phtml
getProductDetailsHtml
renders for non saleable products
Added options logic
<?php $options = $block->getData('viewModel')->getOptionsData($_product); ?>
<?php foreach ($options as $optionItem): ?>
<input type="hidden"
name="<?= $escaper->escapeHtml($optionItem['name']) ?>"
value="<?= $escaper->escapeHtml($optionItem['value']) ?>">
<?php endforeach; ?>
strpos
to $pos
to: <?= ($pos && strpos($pos, $viewMode . '-actions')) ?
/* @noEscape */ $secureRenderer->renderStyleAsTag(
$position,
'product-item-info_' . $_product->getId() . ' div.product-item-actions'
) : '' ?>
<?= ($pos && strpos($pos, $viewMode . '-secondary')) ?
/* @noEscape */ $secureRenderer->renderStyleAsTag(
$position,
'product-item-info_' . $_product->getId() . ' div.actions-secondary'
) : '' ?>
<?= $block->getChildBlock('toolbar')->setIsBottom(true)->toHtml() ?>
I'm strongly suggest to compare your design file with core file and make related changes
Insted of passing null in the method strpos() pass an empty string if the variable is null i check the variable first and then use them in code
here is my code
<?php //Modifications 29 August 2022 (hassan)
if(!$pos)
{
$pos = '';
}
if(!$viewMode)
{
$viewMode = '';
}
?>
EDIT:
You may also just use the same syntax used on your question, and use empty()
to make sure your variables are empty or not:
$pos = !empty($pos) ? $pos : '';
$viewMode = !empty($viewMode) ? $viewMode : '';
<?= strpos($pos, $viewMode . '-primary') ?
/* @noEscape */ $secureRenderer->renderStyleAsTag(
$position,
'product-item-info_' . $_product->getId() . ' div.actions-primary'
) : '' ?>