첫째,이 테이블에 대한 모델을 만들 : 공급 업체 \ 모듈 \ 모델 \ 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
<?php
/**
* Copyright © 2015. All rights reserved.
*/
namespace Vendor\Module\Model\Resource\MgicTaxCaculationRate;
class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection
{
/**
* Define resource model
*
* @return void
*/
protected function _construct()
{
$this->_init('Vendor\Module\Model\MgicTaxCaculationRate', 'Vendor\Module\Model\Resource\MgicTaxCaculationRate');
}
}
그런 다음 블록은 단지 이러한 필드에서 System.Xml을 추가하지 않은 이유 그런데
<?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;
}
}
에서?