collection 在 magento2 中从浏览器刷新控制器时,客户模型未检索更新的数据
collection from customer model is not retrieving updated data when controller is refreshed from browser in magento2
我创建了一个自定义前端模块,用于打印从客户模式检索到的数据(客户详细信息)。当我从浏览器调用控制器时一切正常,我正在以 table 格式打印客户详细信息因为我 required.later 我在 phpmyadmin 控制台中手动更新了客户数据。现在我正在 刷新控制器 。但是 没有打印更新的数据.i 需要删除生成文件并使用 php bin/magento setup:magento 更新自定义模块以获取客户模型的更新数据
这是我的collection文件写在块文件夹
没有检索到更新的数据可能是什么问题...???请讨论
<?php
namespace MageClass\First\Block;
class Details extends \Magento\Framework\View\Element\Template
{
protected $_gridFactory;
public function __construct(
\Magento\Framework\View\Element\Template\Context $context,
\Magento\Customer\Model\CustomerFactory $gridFactory,
array $data = []
) {
$this->_gridFactory = $gridFactory;
parent::__construct($context, $data);
//get collection of data
$collection = $this->_gridFactory->create()->getCollection();
$this->setCollection($collection);
$this->pageConfig->getTitle()->set(__('Users List'));
}
protected function _prepareLayout()
{
parent::_prepareLayout();
if ($this->getCollection()) {
// create pager block for collection
$pager = $this->getLayout()->createBlock(
'Magento\Theme\Block\Html\Pager',
'mageclass.first.record.pager'
)->setCollection(
$this->getCollection() // assign collection to pager
);
$this->setChild('pager', $pager);// set pager block in layout
}
return $this;
}
/**
* @return string
*/
// method for get pager html
public function getPagerHtml()
{
return $this->getChildHtml('pager');
}
}
?
>
我终于找到了答案。实际上问题是 cache.i 在管理员的缓存管理中禁用了全页缓存 panel.Now 我每次都在检索更新的集合
我创建了一个自定义前端模块,用于打印从客户模式检索到的数据(客户详细信息)。当我从浏览器调用控制器时一切正常,我正在以 table 格式打印客户详细信息因为我 required.later 我在 phpmyadmin 控制台中手动更新了客户数据。现在我正在 刷新控制器 。但是 没有打印更新的数据.i 需要删除生成文件并使用 php bin/magento setup:magento 更新自定义模块以获取客户模型的更新数据
这是我的collection文件写在块文件夹
没有检索到更新的数据可能是什么问题...???请讨论
<?php
namespace MageClass\First\Block;
class Details extends \Magento\Framework\View\Element\Template
{
protected $_gridFactory;
public function __construct(
\Magento\Framework\View\Element\Template\Context $context,
\Magento\Customer\Model\CustomerFactory $gridFactory,
array $data = []
) {
$this->_gridFactory = $gridFactory;
parent::__construct($context, $data);
//get collection of data
$collection = $this->_gridFactory->create()->getCollection();
$this->setCollection($collection);
$this->pageConfig->getTitle()->set(__('Users List'));
}
protected function _prepareLayout()
{
parent::_prepareLayout();
if ($this->getCollection()) {
// create pager block for collection
$pager = $this->getLayout()->createBlock(
'Magento\Theme\Block\Html\Pager',
'mageclass.first.record.pager'
)->setCollection(
$this->getCollection() // assign collection to pager
);
$this->setChild('pager', $pager);// set pager block in layout
}
return $this;
}
/**
* @return string
*/
// method for get pager html
public function getPagerHtml()
{
return $this->getChildHtml('pager');
}
}
?
>
我终于找到了答案。实际上问题是 cache.i 在管理员的缓存管理中禁用了全页缓存 panel.Now 我每次都在检索更新的集合