まず、このテーブルのためのモデルを作成:ベンダー\モジュール\モデル\ MgicTaxCaculationRate.phpベンダー\モジュール\モデル\リソース\ MgicTaxCaculationRate.php
<?php
/**
* Copyright © 2015. All rights reserved.
*/
namespace Vendor\Module\Model\Resource;
class MgicTaxCaculationRate extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb
{
/**
* Model Initialization
*
* @return void
*/
protected function _construct()
{
$this->_init('mgic_tax_calculation_rate', 'mgic_tax_calculation_rate_id');
}
}
\
<?php
/**
* Copyright © 2015. All rights reserved.
*/
namespace Vendor\Module\Model;
class MgicTaxCaculationRate extends \Magento\Framework\Model\AbstractModel
{
/**
* Constructor
*
* @return void
*/
protected function _construct()
{
parent::_construct();
$this->_init('Vendor\Module\Model\Resource\MgicTaxCaculationRate');
}
}
\
\ Vendor \ Module \ Model \ Resource \ MgicTaxCaculationRate \ Collection.php
あなただけSystem.Xmlのためにこれらのフィールドを追加しなかった理由ところで0
次に、あなたのブロックで
<?php
namespace Vendor\Module\Block;
class Example extends \Magento\Framework\View\Element\Template
{
protected $_mgicFactory;
public function _construct(
\Magento\Framework\View\Element\Template\Context $context,
\Vendor\Module\Model\MgicTaxCaculationRate $mgicFactory
){
$this->_mgicFactory = $mgicFactory;
parent::_construct($context);
}
public function _prepareLayout()
{
$mgic = $this->_mgicFactory ->create();
$collection = $mgic->getCollection();
foreach($collection as $item){
var_dump($item->getData());
}
exit;
}
}
?