是的......我想我已經找到了一個解決方案。我添加了名稱爲'LLC'的捆綁產品,並添加了簡單的產品作爲複選框。我需要做的是顯示我在LLC捆綁產品下添加的簡單產品的名稱,而不是顯示LLC及其複選框(默認情況)。
顯示覆選框的方式在文件中定義: 應用程序/設計/前端/鹼/默認/模板/束/目錄/產品/視圖/類型/束/選項/ checkbox.phtml
所以我這裏有定義的功能這樣的..
<?php
if($this->htmlEscape($_option->getTitle())=="LLC")
{
$current_product=Mage::registry('current_product');
echo $this->getpackagedetails($current_product,$this->htmlEscape($_option->getTitle()));
}
?>
,你可以看到,我檢查了包項目的名稱爲有限責任公司或沒有。如果是,請將當前產品轉換爲變量,然後調用複選框塊中定義的函數'getpackagedetails()',您可以在這裏找到/ app/code/core/Mage/Bundle/Block/Catalog/Product /View/Type/Bundle/Option.php。該函數傳遞兩個參數:當前產品和包項目名稱。
現在將我們的函數添加到塊文件中。它在下面給出。
<?php
public function getpackagedetails($currentproduct,$optid)
{
$display="";
$bundled = Mage::getModel('catalog/product');
$bundled->load($currentproduct->getId());
$selectionCollection = $bundled->getTypeInstance(true)->getSelectionsCollection(
$bundled->getTypeInstance(true)->getOptionsIds($bundled), $bundled);
foreach($selectionCollection as $option)
{
$sku=$option->getSku();
if($optid=="LLC" && $optid==$bistype)
{
if(strpos($sku,"llc")!== false)
{
$display.=$option->getName();
}
}
}
return($display);
}
這裏我所做的是我已經使用變量$ bundled加載我的當前產品。然後,我將所有選擇類型選項添加到我的捆綁產品中,並添加到變量$ selectionCollection中。爲了分離與LLC捆綁產品相對應的選項,我檢查了每個選項的sku中是否存在'llc'字符串(所有簡單產品都對應於LLC捆綁產品,我在那裏設置了'llc'字符串) 。如果是,那麼獲取名稱並將其存儲到變量$ display中。然後返回該變量。
多數民衆贊成它。現在您只能看到我爲名稱爲LLC的捆綁產品添加的簡單產品名稱。