我產生了一些使用Magmi和一些自定義代碼捆綁產品:程序生成的附贈產品不顯示在目錄頁
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
$storeID = 1;
$websiteIDs = array(1);
error_reporting(E_ALL);
ini_set('display_errors',1);
//Get bundled products
$products = Mage::getModel('catalog/product')->getCollection()
->addAttributeToSelect('*')
->addAttributeToSelect('type')
//->addAttributeToFilter('type_id', 'bundle') // simpler..
->addFieldToFilter('type_id', array('eq' => 'bundle')) // simple/configurable etc
;
foreach ($products as $product){
$parentProduct = clone $product;
// get all the options of your bundle product assumed as $bundle
// remove the Selection/Bundle association from database, we need to pass all the others except the one we need to drop
Mage::getModel('bundle/mysql4_bundle')->dropAllUnneededSelections();
$options = $product->getTypeInstance()->getOptionsCollection();
foreach ($options as $option){
$option->delete();
}
$simple_skus = explode(",",$product->getBundledSkus());
$items = array();
$selections = array();
$simple_skus = array_reverse($simple_skus);
foreach ($simple_skus as $sku){
if ($sku == '')continue;
$selectionRawData = array();
$pos = 0;
$pos++;
$productId = $product->getIdBySku($sku);
$simple = $product->load($productId);
$items[] = array(
'title' => $simple->getName(),
'parent_id' => $parentProduct->getId(),
'option_id' => '',
'delete' => '',
'type' => 'checkbox',
'required' => (strpos($sku,'harness') !== false ? 1 : 0),
'position' => $pos);
$selections[][] = array(
'selection_id' => '',
'option_id' => '',
'product_id' => $simple->getEntityId(),
'delete' => '',
'selection_price_value' => $simple->getPrice(),
'selection_price_type' => 0,
'selection_qty' => 1,
'selection_can_change_qty' => 0,
'position' => 0);
}
Mage::unregister('product');
Mage::unregister('current_product');
Mage::register('product', $parentProduct);
Mage::register('current_product', $parentProduct);
$parentProduct->setCanSaveConfigurableAttributes(false);
$parentProduct->setCanSaveCustomOptions(true);
如果你看一下它,它在後端,一切似乎都被設置如果你輸入網址,你可以直接訪問一個產品,它可以工作,可以將它添加到購物籃等 - 參見http://autosparks.absolute-staging.co.uk/src/trunk/seat-belt-harness.html作爲一個例子。
但是,即使通過將產品分配到正確的類別,它也不會返回任何類別或搜索上的產品。
如果我在後端創建捆綁產品,使用與生成的捆綁包完全相同的值,並且它按預期工作並顯示。
有幾件事情我已經嘗試:
- 我已經重新索引(很多很多次)
- 我已經清除緩存
- 我已經截斷所有Magento的產品表,平表等,並從頭開始重新進口
- 我試圖複製進口產品之一,並從它
- 產品節能新產品均有現貨
- 捆綁的產品搜索的可見性,目錄
- 簡單的產品具有不單獨可見
能見度我敢肯定,我已經錯過了一些東西很明顯,表我需要更新或東西,但我不確定是什麼!
如果您在保存啓用時重新索引,從管理員點擊保存這些新產品,它會顯示嗎?如果是這樣,這是一個你遺漏的地方缺失的屬性。在每個目錄產品實體表中需要比較好的產品和不好的屬性是我的選擇。 – Ashley
嗨@AshleySwatton感謝您的留言。不,從後端重新保存產品並不會令人傷心。 –
不幸的是,解決方案將在數據庫的某個地方。手動創建一個與admin中生成的相同的產品,並通過以catalog_開頭的數據庫中的每個表跟蹤它。從product_entity表開始,從那裏開始向外工作。記下正在使用的產品和非使用產品的所有屬性ID和值,直到找到不同的東西,然後手動爲壞產品添加或更改它,重新索引和重新測試。 catalog_product_website已經讓我知道了。祝你好運。 – Ashley