【问题标题】:Magento - Newly added products not showingMagento - 未显示新添加的产品
【发布时间】:2014-04-22 07:19:28
【问题描述】:

我从 Magento 后端创建了一个新产品,但它没有显示在相关类别下或它自己的产品页面中。即,如果我输入产品 url 密钥,它会转到 404 页面。

这只是一个简单的产品,我检查了以下内容,

Product enabled : Yes

Visibility : Catalog, search

Product Images : All good

Quantity Available : 9999999

Stock Availability : In Stock

Assign to a category : Yes (I even went to Manage Category to see product is under Category products and its there)

Product in web sites : Assigned

Cache : Cleared 10 X times

Indexing : Done

我又做了一件事,我查看了 app/code/core/Mage/Catalog/Model/Category.php 并在 getProductCollection() 函数中添加以下行 return $collection 之前

var_dump($collection->getAllIds());

然后我转到类别页面,我可以看到 var_dump 输出分配给该类别的所有产品 ID,但我仍然没有新产品:(

这真是令人沮丧,花了我一整天的时间,没有运气,有什么想法吗?

更新:

刚刚发现可以通过http://my.host/catalog/product/view/id/881手动导航到产品页面

但在页面中显示“...此项目当前不可用”,只需深入研究代码并查看显示此消息的原因并发现 $_product->isSaleable() 返回 false。

但我不确定与产品有关的天气在类别中不可见,并且无法通过 URL 键导航

【问题讨论】:

  • 索引——你缺少的东西
  • 是的,我也补充一下 :)
  • 产品分配到的类别是商店根类别的子类别?

标签: php magento product


【解决方案1】:

终于设法解决了这个问题。我将解释我为解决此问题所做的工作,因为它也可能对其他人有所帮助。

就像我在问题中所说的那样,我做了我的清单。但是$_product->isSaleable() 正在返回false

所以我不得不深入研究代码,发现$_product->isSaleable() 设置在Mage_CatalogInventory_Model_Stock_Status::assignProduct() 中。

public function assignProduct(Mage_Catalog_Model_Product $product, $stockId = 1, $stockStatus = null)
    {
        if (is_null($stockStatus)) {
            $websiteId = $product->getStore()->getWebsiteId();
            $status = $this->getProductStatus($product->getId(), $websiteId, $stockId);
            $stockStatus = isset($status[$product->getId()]) ? $status[$product->getId()] : null;
        }

        $product->setIsSalable($stockStatus);

        return $this;
    }

然后我发现$this->getProductStatus();返回了一个空数组,原因是cataloginventory_stock_status表中没有我的新产品的条目。

此表仅在 Stock Status index 重建时更新,在 Magento admin 中都是 Green"Ready",但是它不是真的“准备好” :(。

所以我运行shell/indexer.php --reindexall 来手动重新构建我的所有索引,这也更新了cataloginventory_stock_status 表。

终于可以看到我的产品了。耶!!

@Kingshuk Deb - 所以你是对的,它是索引,但 Magento 管理员说这一切都很好,这从一开始就误导了我。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多