我想隱藏沒有任何圖像關聯的可配置選項。我試圖重寫可配置的產品塊,但它不起作用。任何人有任何想法呢?如何從Magento可配置選項中隱藏圖像項目?
0
A
回答
0
我認爲一個好的解決方案是將所有沒有任何圖片的簡單產品設置爲缺貨,並將配置system->catalog->inventory->stock options->Display Out of Stock Products
設置爲no。
如果您有產品導入邏輯,則可以將該代碼集成到該代碼中。
0
我得到了解決方案。 我注意到,可配置的產品選項來自位於Mage_Catalog_Block_Product_View_Type_Configurable
區塊的功能$this->getJsonConfig();
。我所做的是,我在我的模塊中重寫了這個塊,並通過在其中放置下面的代碼來改變函數。
public function getJsonConfig()
{
$attributes = array();
$options = array();
$store = $this->getCurrentStore();
$taxHelper = Mage::helper('tax');
$currentProduct = $this->getProduct();
$preconfiguredFlag = $currentProduct->hasPreconfiguredValues();
if ($preconfiguredFlag) {
$preconfiguredValues = $currentProduct->getPreconfiguredValues();
$defaultValues = array();
}
foreach ($this->getAllowProducts() as $product) {
if($product->getImage() && $product->getImage() != 'no_selection'){
$productId = $product->getId();
foreach ($this->getAllowAttributes() as $attribute) {
$productAttribute = $attribute->getProductAttribute();
$productAttributeId = $productAttribute->getId();
$attributeValue = $product->getData($productAttribute->getAttributeCode());
if (!isset($options[$productAttributeId])) {
$options[$productAttributeId] = array();
}
if (!isset($options[$productAttributeId][$attributeValue])) {
$options[$productAttributeId][$attributeValue] = array();
}
$options[$productAttributeId][$attributeValue][] = $productId;
}
}
}
我只是讓產品foreach循環添加if($product->getImage() && $product->getImage() != 'no_selection'){
。這隻會將圖像項目過濾到可配置選項json對象數組。
相關問題
- 1. Magento可配置選項
- 2. Liferay WebContentDisplay - Portlet - 隱藏配置選項卡
- 3. magento可配置產品選項
- 4. 隱藏可配置產品的一些選項
- 5. 如何隱藏aci樹中的項目
- 6. 如何隱藏TabActivity中的選項卡?
- 7. jquery ui中的可選圖像項目
- 8. 如何隱藏.git項目目錄?
- 9. 隱藏項目類
- 10. 隱藏TabBar項目
- 11. 從ListView控件中隱藏項目
- 12. Recyclerview:隱藏項目,而不從ArrayList中
- 13. JIRA中的隱藏項目
- 14. 在eclipse中隱藏項目
- 15. 如何隱藏項目列表中的Trac項目?
- 16. 如何隱藏Android選項卡布局中的選項卡?
- 17. 如何配置隱藏圖層中DNNClassifier
- 18. 圖例項目隱藏/顯示其他圖例項目
- 19. 隱藏選擇多個項目Django
- 20. 隱藏選擇項目,如果另一個選擇項中選擇
- 21. Magento。可配置產品 - 選擇2個或更多選項(多個選項)
- 22. 隱藏在我的xcode項目中的圖像
- 23. 如何隱藏標籤欄項目?
- 24. 如何訪問隱藏的RecyclerView項目?
- 25. Android:如何隱藏ListView項目
- 26. 如何隱藏標籤欄項目?
- 27. 如何隱藏UInavigationBar右鍵項目?
- 28. 設置隱藏的datalist選項值
- 29. 隱藏woocommerce設置選項卡
- 30. 如何隱藏使用php的選項。
對不起,重播晚了。我已經從產品列表中刪除了無圖像的項目。現在我需要從可配置中刪除選項。假設一個可配置的有兩個子項目的大小爲S和M. S有圖像,而M沒有。在這種情況下,我只想顯示S.目前,兩者都顯示,當我點擊M時,它顯示無圖像的佔位符。 對不起,您提到的上述解決方案在此不起作用。 –
@JicksonJohnsonKoottala解決方案仍然相關。如果簡單產品缺貨,那麼它將不會顯示在我提到的設置的可配置選項上。 – shemaya
@ shemaya對不起,仍然不是一個好的解決方案。因爲如果我這樣做,我需要提出另一個問題,如何根據圖像狀態來製作缺貨的簡單產品。 ?並且需要在詳細信息頁面上實時完成。我已經自己找到了答案,並在上面發佈。 如果您將產品缺貨,則不會顯示在可配置選項上,這是正確的。但是爲了將它從這個領域隱藏起來而不是一個好的想法。我希望你明白了。 –