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条)

报告相同问题?

悬赏问题

  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图