Magento2的Model是如何进行CURD的?

8.47K 浏览M2交流区

Magento2的Model是如何进行CURD的?

https://gitee.com/zouhongzhao/magento2-action-extension-demo/blob/master/Demo/Block/PhysicalStores.php

有谁知道这个demo/physicalstores/enabled的值是侟在哪张表里面?

0

admin 你理解错了。 $this->isEnabledStaffs()这个方法在 https://gitee.com/zouhongzhao/magento2-action-extension-de ...

https://gitee.com/zouhongzhao/magento2-action-extension-demo/blob/master/Demo/view/frontend/templates/physical_stores.phtml#L67
那好像没必要把$this->isEnabledStaffs()这个判断放在foreach里面。

0

你理解错了。
$this->isEnabledStaffs()这个方法在
https://gitee.com/zouhongzhao/magento2-action-extension-demo/blob/master/Demo/Block/PhysicalStores.php
里面。
$this->getConfig('demo/physicalstores/enabled');
是读取后台configuration页面该插件的设置,是判断这个插件是否启用,如果启用的话就执行,不启用就不执行。
其实这个判断可有可无,看个人需求。主要目的是如果后台该插件的enabled设为no,就不启用执行该插件的功能。

跟$_store->getStatus()没有半毛钱关系。

0

https://gitee.com/zouhongzhao/magento2-action-extension-demo/blob/master/Demo/view/frontend/templates/physical_stores.phtml
```php
  <?php  if  ($this->isEnabledStaffs()):  ?>
                  <a  class="physicalstore-view-btn"  href="<?php %20echo %20$url; %20?>"><?php  echo  __('more  information')  ?>      »</a></p>        
<?php  endif;?>
```php
$this->isEnabledStaffs()  应该改成:$_store->getStatus()  ?

0

https://www.kancloud.cn/zouhongzhao/magento2-in-action/647794

MySQL的Schema对应如上

0

admin core_config_data表里

多谢。

但是看模板文件:
https://gitee.com/zouhongzhao/magento2-action-extension-demo/blob/master/Demo/view/frontend/templates/physical_stores.phtml

isEnabledStaffs(), 感觉是应该对应到physical_stores表的  status 字段?
意思是看这个店铺的状态?
若是存在core_config_data,显然是应该放在foreach 循环外面。

0

core_config_data表里

0