1 回答

TA貢獻(xiàn)1865條經(jīng)驗(yàn) 獲得超7個(gè)贊
首先,您的 HTML 不在循環(huán)中。其次,只需增加一個(gè)計(jì)數(shù)器并檢查 10 和break:
$i = 0;
foreach ($subCats as $subcat) {
if($i == 10) { break; } $i++;
$_category = $objectManager->create('Magento\Catalog\Model\Category')->load($subcat->getId());
$subcaturl = $subcat->getUrl();
?>
<li class="cat-li" style="list-style-type: none;">
<div class="product-item-info">
<div class="product-item-details">
<ul class="productsub-categories" style="text-align: left;">
<a href="<?php echo $subcaturl; ?>">
<strong ><?php echo $subcat->getName(); ?></strong>
</a>
</ul>
</div>
</div>
</li>
<?php }
echo "Your view all link";
- 1 回答
- 0 關(guān)注
- 194 瀏覽
添加回答
舉報(bào)