小编Ian*_*Ian的帖子

将Select2与Magento 2集成

我正在尝试将Select2与Magento2集成。到目前为止,我已经成功集成了插件,但是控制台上显示错误。 在此处输入图片说明

我所做的:

  1. 下载了select2.min.js并将其放入 app/design/frontend/<vendor>/<themename>/web/js/select2.min.js
  2. 包含脚本 app/design/frontend/<vendor>/<themename>/Magento_Theme/layout/default_head_blocks.xml
  3. 将此添加到脚本标签中的phtml文件中:

    require(['jquery'],function(jquery){ jquery(document).load(function() { jquery("#sorter2").select2(); }); });

我知道我应该通过requireJS包含它,但是我似乎无法使其工作。

谢谢!

requirejs magento2 select2

5
推荐指数
1
解决办法
1335
查看次数

获取登录客户Magento 2.0的默认结算/送货地址

这是我使用Magento 2的第一个项目.我很难获得登录客户的默认账单/送货地址,以显示在我的自定义模块的前端.

到目前为止我有这个:

//this gets the billing id which is an integer. I'm thinking it must be loaded to get the whole data of the address
$billingId =  $customerSession->getCustomer()->getDefaultBilling();

//just found this in the internet and thought it might be the same as loading an order, but it doesn't work
$address = $objectManager->create('\Magento\Customer\Model\AddressFactory')->load($billingId);
Run Code Online (Sandbox Code Playgroud)

但错误说: Call to undefined method Magento\Customer\Model\AddressFactory::load()

我想我很接近,但我不知道接下来该做什么.提前致谢.

php frontend magento magento2

3
推荐指数
1
解决办法
1万
查看次数

标签 统计

magento2 ×2

frontend ×1

magento ×1

php ×1

requirejs ×1

select2 ×1