donglu7816 2013-12-01 15:53
浏览 55
已采纳

我在哪里可以找到Magento中函数的定义?

I'm helping a friend with his Magento website and I have very little PHP and Magento experience. I haven't had to do too much when it comes to the actual code, but there's one change we want to make that actually involves changing code.

The code contains something like this:

$model = Mage::getModel('catalog/product');
$_product = $model->load($entity_id);
$bedroom = $_product->getTotalrooms();

The above works fine, and I'd like to add the following:

enter code here`$bathroom = $_product->getTotalbathrooms();

I've added totalbathrooms to the Attributes page and tried to make it identical to totalrooms, the only difference I see right now is that in the System column, for totalrooms it says Yes but for totalbathrooms it says No. I've updated the html in the forms to add new places and updated the html of the product page, but currently it isn't displaying the no. of bathrooms. You can see an example product here: http://book.bnbtlv.com/index.php/bathroom-test.html. If you scroll to the middle of the page, you'll notice that there's no value for bathrooms. Bedrooms is 4 however.

One question I have is whether getTotalrooms was defined anywhere or if it was created automatically somehow? If it was defined manually, then where would is that so I can also define getTotalbathrooms there? Also, where would I find the place where setTotalrooms is called? I'm guessing that setTotalbathrooms is never called for my products at the moment.

Lastly, when I go to the Manage Products page on the admin page and click on a product and then click Product Information, I see the no of rooms, but I don't see the number of bathrooms. How can I get the number of bathrooms to display on this page and be editable by the admin?

Thanks

  • 写回答

2条回答 默认 最新

  • dronthpi05943 2013-12-01 17:06
    关注

    Firstly, getTotalRooms() is not defined anywhere in nmagento, it gets picked up from the attribute you created.

    I think your problem is that you have missed out adding the created attribute to your attribute set and then re-index data, using the re-indexing options.

    After creating attribute on the attribute page you will need to add that Attribute to the attribute set that your product is using.

    Refer to this video : http://www.youtube.com/watch?v=MqhCcCpR4DI

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记