Magento

Magento电子商务平台用户的问答


2
如何在首页Magento 2上显示色板
我有两个产品滑块 (基于\Magento\Catalog\Block\Product\Widget\NewWidget)在我的首页上。 我想将色板添加到这些产品滑块。 滑块添加到我的homepage.xml布局中,如下所示: <container name="items.wrapper.slider" after="full.width.white.bar" htmlTag="div" htmlClass="wrapper wrapper--large c-catalog__products--slider-wrapper"> <block class="Silvan\TestExtension\Block\Product\Widget\NewWidget" template="Magento_Catalog::product/widget/new/content/new_grid.phtml" name="new.products"> <block class="Magento\Swatches\Block\Product\Renderer\Listing\Configurable" as="new.products.swatches" template="Magento_Swatches::product/listing/renderer.phtml" /> </block> </container> 我试图通过添加带有类的块来添加色板,Magento\Swatches\Block\Product\Renderer\Listing\Configurable但这不能按预期工作。 有人知道如何在首页中实现这一目标吗? 谢谢。

1
自定义Magento 2主导航(topmenu)javaScript
我花了很多时间研究主题模块和空白模板,以尝试更改Magento2的主要导航。到目前为止,我已经制作了一个自定义模块来控制呈现到页面中的内容(向subnav添加链接),但是我无法确定导航菜单javaScript的位置。 我可以在空白模板中看到一个navigation.menu.js文件,在主题模块中看到了menu.js,但是这些似乎都不是主菜单,而且找不到其他地方可以找到JS。 因为该块是由XML生成的,并且导航似乎在jQuery UI上运行,所以我没有太多可以用来搜索的内容。到目前为止,我主要是通过搜索供应商目录来修改基于基础模板构建的自定义模板,但是我还是空白。 我正在运行Magento 2.1,并在基础模板的基础上构建了自定义模板,如果有人可以向我指出正确的方向,那将是很大的帮助。 编辑1: 因此,经过更多的谷歌搜索和测试之后,我终于在lib / web / mage中找到了第二个menu.js文件,这似乎是正确的位置,但是现在我无法覆盖它。 有了我的新信息,我实际上偶然发现了Magento2开发文档,其中有一个覆盖菜单和管理菜单的示例。所以我在模块中添加了以下内容 命名空间/模块/视图/前端/require-config.js var config = { map: { '*': { 'menu': 'Test_Topmenu/js/navigation-menu' } } }; 命名空间/模块/视图/前端/web/js/navigation-menu.js define([ 'jquery', 'jquery/ui', 'mage/menu' ], function ($) { "use strict"; $.widget('Test_Topmenu.navigationMenu', $.mage.menu, { _init: function () { console.log('new init'); } }); return …


1
如何使用REST API v2创建可配置产品?
我正在尝试创建一个名为“ Kudos Configurable”的可配置产品,其中的选项供用户从小绿色,大绿色,小橙色和大橙色中选择。 我已经到了通过对/ rest / V1 / products / KudosConfig的PUT请求中使用以下JSON通过API创建可配置产品的阶段。 { "product":{ "sku":"KudosConfig", "name":"Kudos Configurable", "price":30.00, "status":4, "type_id":"configurable", "attribute_set_id":4, "weight":1, "extension_attributes":{ "stock_item":{ "qty":10, "is_in_stock":true } } } } 子产品是使用API​​使用以下JSON创建的,用于以下4个项目中的每个项目,并通过相同的方法设置了尺寸和颜色属性。 { "product":{ "sku":"KudosConfigGreenSmall ", "name":"Kudos Configurable Green Small", "price":30.00, "status":0, "type_id":"virtual", "visibility":1, "attribute_set_id":4, "weight":1, "extension_attributes":{ "stock_item":{ "qty":10, "is_in_stock":true } }, …

7
如何获取特定产品的所有图像
如何通过使用此代码获取特定产品的所有图像,我只能获取特定产品的单个图​​像。。 请帮助我是新来的。 <?php // Get products in category require_once('../app/Mage.php');//Path to Magento umask(0); if(isset($_GET["categoryId"])){ $categoryId=$_GET["categoryId"]; $proxy = new SoapClient('http://www.prashant.com/index.php/api/v2_soap/?wsdl'); // TODO : change url $sessionId = $proxy->login('prash', 'prashant123@'); // TODO : change login and pwd if necessary $products= $proxy->catalogCategoryAssignedProducts($sessionId,$categoryId); $itemDetails=array(); Mage::app(); foreach ($products as $item) { $product2 = Mage::getModel('catalog/product')->load($item->product_id); $productMediaConfig = …

2
Magento 2提供了一种更快的方式以编程方式更改产品媒体库条目
我需要对产品数据进行大量更新,但是产品导入无法实现我需要做的事情。例如,我需要更新给定产品的媒体库和类别,但是我提出的解决方案花费的时间太长。 简要回顾一下:我在Magento 2 CLI中添加了一个命令,给定json配置文件,该命令可以为这样的给定产品删除,添加,更新或排序媒体库条目。在这里粘贴代码摘录: /* $product is of type Magento\Catalog\Model\Product */ //get existing media gallery $existingMediaGallery = $product->getMediaGallery(); /* do stuff with media gallery (alter $existingMediaGallery) (add, remove, sort, ...) */ //set media gallery again $product->setMediaGallery($existingMediaGallery); //process media gallery $mediaGalleryEntries = $product->getMediaGalleryEntries(); $this->getMediaGalleryProcessor()->clearMediaAttribute($product, array_keys($product->getMediaAttributes())); if ($mediaGalleryEntries) { foreach ($mediaGalleryEntries as …


5
Magento2:获取产品的图像路径
我创建了用于获取产品的自定义页面。我得到了所有信息,但是如何获得完整的图像路径。我正在使用getImage()它只显示图像如何获取完整路径。 <a href="<?php echo $this->getBaseUrl().$_item->getUrlKey();?>" title="<?php echo $_item->getName() ?>" class="product-image"><img src="<?php echo $this->getImage();?>" alt="<?php echo $_item->getName() ?>" />

2
如何在magento2的产品网格中添加大众化?
我需要根据设置添加群众活动。 如果在“配置”设置中将其设置为“是/启用”,则仅应将特定的质量作用添加到产品网格中。 我知道我可以使用ui_component product_listing.xml直接添加大规模行动。?但是情况是如何检查配置设置并基于此添加或删除呢?
8 magento2 

4
Magento 2:所选类别在编辑表单中不可见
使用ui组件以管理形式添加了类别选择器。类别ID作为逗号分隔的值保存到数据库中。现在,我想在我的编辑表单中显示该类别。 这是我的example_example_edit.xml文件: <?xml version="1.0"?> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> <body> <referenceContainer name="content"> <uiComponent name="example_form"/> </referenceContainer> </body> </page> 这是我的example_form.xml <?xml version="1.0" encoding="UTF-8"?> <form xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd"> <argument name="data" xsi:type="array"> <item name="js_config" xsi:type="array"> <item name="provider" xsi:type="string">example_form.example_form_data_source</item> <item name="deps" xsi:type="string">example_form.example_form_data_source</item> </item> <item name="label" xsi:type="string" translate="true">example Information</item> <item name="config" xsi:type="array"> <item name="dataScope" xsi:type="string">data</item> <item name="namespace" xsi:type="string">example_form</item> </item> …

1
Magento_Ui / js / lib / knockout / extender / bound-nodes RequireJS模块做什么?
Magento 2中的Knockout.js引导程序模块通过define依赖项包含以下模块。 Magento_Ui/js/lib/knockout/extender/bound-nodes 从技术上讲,此模块为ko.applyBindings和ko.cleanNode方法创建包装器。这些包装器将某些视图模型和节点存放在私有javascript中WeakMap,然后返回一个注册表对象,使您可以访问WeakMap。 但是,尚不清楚此功能使最终用户程序员面对哪些功能。这里有人知道Magento_Ui/js/lib/knockout/extender/bound-nodes模块的实际用途吗?还是对Knockout.js内部结构很熟悉以解决问题?

1
通过插件无法在magento 2中保存自定义付款字段数据,
我正在尝试通过插件保存我的自定义字段数据,但是它不起作用。 插件类 namespace Vendor\Module\Model\Checkout; class PaymentInformationManagementPlugin { protected $paymentMethodManagement; public function __construct( \Magento\Quote\Model\QuoteFactory $quote, \Magento\Quote\Api\PaymentMethodManagementInterface $paymentMethodManagement ) { $this->paymentMethodManagement = $paymentMethodManagement; $this->quoteManagement = $quoteManagement; } public function beforeSavePaymentInformation( \Magento\Checkout\Model\PaymentInformationManagement $subject, $cartId, \Magento\Quote\Api\Data\PaymentInterface $paymentInformation ) { //$paymentInformation->getData('extension_attributes'); $extenstinAttributes = $paymentInformation->getExtensionAttributes(); $taxCode = $extenstinAttributes->getTaxCode(); $paymentInformation->setExtensionAttributes($taxCode); $this->paymentMethodManagement->set($cartId, $paymentInformation); return true; // var_dump($taxCode);exit; // …

2
Magento2正确顺序以刷新所有缓存/静态文件
我在Magento2中使用生成的类,预处理的文件和缓存进行开发时遇到了困难。 与Magento1相比,禁用所有缓存时似乎无法再有效开发,此外,我还需要查看缓存是否干扰了我构建的功能。 我的问题是,缓存和生成的文件太多了,我不确定它们之间是相互依赖的,我不确定应该以什么顺序刷新它们以便对我的所有开发情况有一个全新的了解。 有后端缓存区域 所有可以清除的标准缓存 目录图像缓存 静态文件缓存 CSS / JS缓存 然后是bash命令 php bin / magento缓存:干净 php bin / magento设置:静态内容:部署 然后有可以手动删除的文件夹 变/代 var /缓存 var / page_cache var / view_preprocessed pub / static 那有很多可能性,可能不是全部。因此,如果我部署大型更新,则代码更改,CSS / JS更改,模板更改 我应该执行以下哪些步骤来清洁所有物品?这些步骤必须按什么顺序执行?

2
使用不同的转义方法
我注意到类vendor/magento/framework/Escaper.php,其中包含一些(主要是)模板内部使用的有用的安全方法。其中一些很常见(escapeHtml()),但其中一些很难遇到。 什么方法escapeXssInUrl()真正起作用? 如果是方法escapeJsQuote()-在哪里可以找到这些引号?仅内联js模板? 当应使用所有方法时(实践示例),有人对它有清晰的解释吗? 是什么之间的差异escapeUrl()和escapeXssInUrl(),如果第二个赠款我们更好的安全性,为什么不总是使用第二个,而不是仅逃逸HTML字符? escapeQuote()应该用于例如在<div value="<?php echo[[here?] 这样的情况下回显某些变量$value?>"></div>?

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.