金额带符号
引用助手函数
示例:
use Webkul\Marketplace\Block\Transaction\History;
$this->history->getFormatedPrice("100")
调用AJAX响应后在前端显示信息
//继承自Action的方法,无需另外引用
$this->messageManager->addSuccessMessage("成功的消息");
使用缓存存储数据
示例:
use Magento\Framework\App\Cache;
public function __construct(Cache $cache){
$this->cache = $cache;
//用于在缓存中保存数据
$this->cache->save($data, $identifier, $tags, $lifeTime);
//如果你想保存在数组中,你需进行序列化
$data = $this->serializer->unserialize($data)
$identifier - unique identifier of the stored information block.
$tags = array of tags - may be empty.
//读取数据
$this->cache->load($identifier)
}