Issue
I have coded a widget for Magento 2.3 that lists subcategories based on a parent category ID entered into the Magento admin panel. If there are more than 10 subcategories listed, it displays a "View All" link so the visitor can view all additional subcategories.
The link is conditional, where if there is no subcategory, it should display the "View All" link and link to the parent category that is being pulled from the admin panel. However, I cannot find the correct parameters for the parent category. This is my code minus the correct parameters:
<a href="<?php if (!empty($subcat)) {echo $subcat->getParentCategory()->getUrl();} else {echo MISSING_PARENT_CAT_URL_PARAMETER;} ?>">View All Categories...</a>
Solution
<?php if ($i >= '$numberofcats') { ?>
<a href="<?php {echo $subcat->getParentCategory()->getUrl();}?>">View All</a>
<?php } else { echo '';} ?>
Answered By - Petey88 Answer Checked By - David Goodson (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.