如何通过观察者模块在产品名称和简短描述之间插入 html 代码

How to insert html code between product name and short description by observer module

我编写了一些价格操纵模块。但是现在我需要在产品视图和目录列表中的产品名称和简短描述之间插入 div 块。我可以在我的模块中这样做吗?我如何通过修改我的模块来做到这一点?我基于此编写的模块

Shusha_Clockdown.xml

<?xml version="1.0"?> <config>
<modules>
    <Shusha_Clockdown>            <active>true</active>
        <codePool>local</codePool>
        <depends>
            <Mage_Catalog />
        </depends>
    </Shusha_Clockdown>
</modules> </config>

Observer.php

<?php
 class Shusha_Clockdown_Model_Observer {
  public function changeprice($observer) {

      $event = $observer->getEvent();
      $_product = $event->getProduct();
          // добавляем доллар к простым продуктам
          if ($_product->getSuperProduct() && $_product->getSuperProduct()->isConfigurable()) {
      } else {            
          $_product->setFinalPrice(50);
      }

      return $observer;
  }
 }

为了生成 html,我使用 module.phtml,但我不知道它必须存储在哪里。

我尝试 this solution,添加到 xml,将我的 .phtml 存储在文件夹 - /app/design/frontend/theme/default/template/catalog/product 中,但没有结果。

如果你需要在观察者中添加块(一个接一个),你可以使用以下方法: 在扩展的 config.xml 中创建一个观察者: https://gyazo.com/69b8050ce3c7f1f2f11d874895791b68

在观察者中添加一个方法: https://gyazo.com/11db8562a9eb3d874cc0ac8c4d01ba0d

接下来,在您的块及其模板中,添加您需要的内容(我那里只有一个文本标签)。
https://gyazo.com/b13f7efb93694d77c0c3c2046617529a

结果将是: https://gyazo.com/25356b81fb20891b3da3fc53a1cafd5c

至于缺点,最大的可能就是很难找到添加这段代码的地方。另请注意,价格块在布局中没有自己的名称,因此,此方法将在每个价格块之后添加自己的自定义块。

因此,只有在没有其他选项可以更改模板和布局时才应使用该方法。如果您可以编辑产品模板,只需在其中插入您的块并通过您的扩展布局添加它。