【问题标题】:Magento 1.9.1.0 No Thumbnail Image in Category MenuMagento 1.9.1.0 类别菜单中没有缩略图
【发布时间】:2015-01-08 03:24:33
【问题描述】:

有没有办法在导航菜单中添加缩略图? Magento 1.9.1.0 在 Magento 管理面板中删除了此功能。您对此有什么建议吗?

谢谢,

【问题讨论】:

  • 只需安装示例数据,然后截断产品、类别、订单和属性表。通过删除此数据,缩略图字段仍然可见。这是一种方法,如果你得到另一种方法,请告诉我们。我也有同样的错误
  • 您好 Shijin,您的意思是仅使用示例数据安装?我需要用产品填充我的网站吗?那么类别中的缩略图会显示吗?让我知道。谢谢,
  • 我发布了一个我会尝试的答案,请检查。但要小心attribute_id

标签: magento magento-1.9.1


【解决方案1】:

我通过在我的 phpMyAdmin 中运行以下查询来解决此问题,

1)

 INSERT INTO `eav_attribute` (`attribute_id`, `entity_type_id`, `attribute_code`, 
`attribute_model`, `backend_model`, `backend_type`, `backend_table`, `frontend_model`, 
`frontend_input`, `frontend_label`, `frontend_class`, `source_model`, `is_required`, 
`is_user_defined`, `default_value`, `is_unique`, `note`) VALUES(140, 3, 'thumbnail', NULL, 
 'catalog/category_attribute_backend_image', 'varchar', NULL, NULL, 'image', 'Thumbnail
 Image', NULL, NULL, 0, 0, NULL, 0, NULL);

2)

 INSERT INTO `catalog_eav_attribute` (`attribute_id`, `frontend_input_renderer`, 
`is_global`, `is_visible`, `is_searchable`, `is_filterable`, `is_comparable`, 
`is_visible_on_front`, `is_html_allowed_on_front`, `is_used_for_price_rules`, 
`is_filterable_in_search`, `used_in_product_listing`, `used_for_sort_by`, 
`is_configurable`, `apply_to`, `is_visible_in_advanced_search`, `position`, 
`is_wysiwyg_enabled`, `is_used_for_promo_rules`) VALUES 
 (140, NULL, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, NULL, 0, 0, 0, 0);

3)

INSERT INTO `eav_entity_attribute` (`entity_attribute_id`, `entity_type_id`,  
`attribute_set_id`, `attribute_group_id`, `attribute_id`, `sort_order`) 
VALUES (337, 3, 3, 4, 140, 3);

这里我使用 attribute_id 作为 140,在这些查询中使用一个唯一值的 id

要在前端显示此图像,我们可以使用

  <?php $thumbnail = $_category->getThumbnail(); ?> 
  <?php if($thumbnail): ?>

   <img src ="<?php echo Mage::getBaseUrl('media').'catalog' . DS . 'category' . DS.$thumbnail; ?>" alt="<?php echo $this->escapeHtml($_category->getName()) ?>"  class="img-responsive"  />    

  <?php endif; ?>   

【讨论】:

  • 即使在运行您的 SQL 之后,我们似乎也不能再使用 getThumbnail() 调用类别缩略图?
  • 所有这些查询所做的就是创建属性,将其添加到数据库中,然后确保它全部链接起来。您实际上是如何在前端显示类别缩略图的?
  • @zigojacko 我用前端代码更新了答案,请检查一下。我只是magento的初学者,我不知道其他方法。:)
  • 你运行的是什么版本的 Magento,你确定是 1.9.X 吗? getThumbnail() 没有为我加载任何内容(该功能甚至在类别模型中都不存在,我必须手动创建它)...
  • @zigojacko 我正在使用 Magento 版本。 1.9.1.0,你用的是哪个版本?
猜你喜欢
  • 2012-05-25
  • 1970-01-01
  • 2012-11-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多