Magento

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



2
addFilter vs addFieldToFilter
Magento集合有两种过滤方法: 1. Varien_Data_Collection_Db::addFieldToFilter 2. Varien_Data_Collection::addFilter 似乎这两种方法都将条件添加到Zend_Db_Select。addFilter带来什么优势?什么时候应该代替它addFieldToFilter?

3
addAttributeToFilter中的多条件(OR和AND)
如何在addAttributeToFilter中创建多条件? 我想要这样的SQL查询结果(附有图像): WHERE ((`e`.`news_from_date` > '2013-09-12') OR (`e`.`news_to_date` < '2013-09-12')) AND ((((`e`.`special_price` IS NULL))) OR (((`e`.`special_price` IS NOT NULL)) AND ((`e`.`special_from_date` < '2013-09-12') OR (`e`.`special_to_date` > '2013-09-12')))) $collection->addAttributeToFilter('special_price', array('null'=>'special_price'), 'left'); 谢谢
19 filter 

1
如何在Magento中创建具有不同域的多个商店
如何在Magento中使用相同的产品,相同的数据库但不同的客户创建具有不同域的多个商店。 范例: 我买了2个域:mystore1.com和mystore2.com(仅供参考:mystore1.com已在运行) 现在,我想添加mystore2.com到mystore2.com具有相同的产品,相同的数据库,但不同的客户。 笔记: 已经通过这种方式进行了测试 请一步一步回答!提供正确答案的赏金。并且不通过引荐链接进行回答。

1
Zend框架版本
CE / PE / EE版本到对应的Zend版本的映射是什么? 如果可能的话,我需要一个在Magento 1.1之前的清单。


1
Magento 2如何应用KnockoutJS绑定
根据对KnockoutJS文档的粗略阅读,初始化一个非常基本的Knockout视图如下所示 // This is a simple *viewmodel* - JavaScript that defines the data and behavior of your UI function AppViewModel() { this.firstName = "Bert"; this.lastName = "Bertington"; } // Activates knockout.js ko.applyBindings(new AppViewModel()); 即-您创建一个旨在用作对象构造函数的javascript函数,实例化该对象,然后将该对象传递到ko.applyBindings全局剔除对象(ko)的方法中 但是,在Magento 2中,如果您使用Grid UI加载后端页面,则Magento将初始化js/core/app.jsRequireJS模块 /** * Copyright © 2016 Magento. All rights reserved. * See COPYING.txt for …

1
致命错误在magento 2中调用我的Block时调用成员函数dispatch()的致命错误
这是我的阻止文件: <?php namespace ChennaiBox\Mymail\Block\Mail; class MailContent extends \Magento\Framework\View\Element\Template { protected $_objectManager; protected $customerSession; public function __construct( \Magento\Customer\Model\Session $customerSession, \Magento\Framework\ObjectManagerInterface $objectManager ) { $this->customerSession = $customerSession; $this->_objectManager = $objectManager; } public function mymailData() { try{ if ($this->customerSession->isLoggedIn()) { $cutomerEmail =(string)$this->customerSession->getCustomer()->getEmail(); echo $cutomerEmail; else{ $this->_redirect('customer/account/login/'); } }catch (Exception $e) { $e->getMessage(); } …


2
如何在正文上添加CSS类[Magento2]
我试图在body标签上添加一个css类,但是无法从body标签的渲染位置找到任何文件。 我需要在body标签上添加一个css类,例如其他类即将到来> page-with-filter page-products page-layout-2columns-left myclasshere 下面的早期版本中的xml代码是在正文上添加类的方法。 <reference name="root"> <action method="addBodyClass"> <classname>my-profile</classname> </action> </reference> 我尝试使用它,但是没有用。 我只需要添加一个带有page-layout-2columns-left模板的类。
19 magento2 

4
Magento 1 EE v 1.14.3.x(和CE 1.9.3.x)中的会话验证失败
我正在照顾一个Magento商店,每天有400-500位访客和40-50个订单。最近系统从Magento EE 1.14.2.4升级到Magento EE 1.14.3.2,我注意到日志中有一些奇怪的异常: exception 'Mage_Core_Model_Session_Exception' in /var/www/.../app/code/core/Mage/Core/Model/Session/Abstract/Varien.php:418 我正在追逐该异常,并且我确实知道该异常已被触发,因为以下会话验证代码无法验证会话: class Mage_Core_Model_Session_Abstract_Varien extends Varien_Object { // ... protected function _validate() { // ... if ($this->useValidateSessionExpire() && isset($sessionData[self::VALIDATOR_SESSION_EXPIRE_TIMESTAMP]) && $sessionData[self::VALIDATOR_SESSION_EXPIRE_TIMESTAMP] < time() ) { Magento使用最新发行版将此if块添加到文件中。这显然是一种制动变化,请参阅下面的更多详细信息。 例外情况经常发生,例如每天十几次。但是除非我在上面的条件中完全符合条件,否则我无法重新创建导致异常的条件。例外最常见于产品详细信息页面和一页结帐的最后一步。该商店是b2b商店,用户必须登录才能查看产品页面或能够结帐,这意味着会话无效/过期时,用户将被重定向到登录页面。目前,对我来说更重要的是在结帐时解决此问题。 从用户的角度来看,发生了什么:用户填充购物车,继续进行结帐并到达最后一步,然后他/她单击“提交订单”按钮,但没有任何反应。在后台,Magento的JS执行AJAX请求,并且JS希望收到JSON,但是如果发生此错误,则会返回登录页面的HTML,JavaScript无法解析该HTML,并且它什么也不做。这对于用户而言超级混乱。 好吧,这不是完整的用户方案,我们联系了用户,他们告诉我们,他们在填充购物车和提交订单之间等待了几天,这实际上很难弄清楚,因为人们根本不记得这一点。 PHP会话生存期-350000(以秒为单位约4天)Cookie生存期-345600(4天) 这是实际的问题: 我如何找出导致这种异常的用户行为? 更新 到目前为止,我知道根据所提出的请求,以下类中会发生异常,对我而言,这并不意味着没有任何异常。 /catalogsearch/result/?q=… Mage_Core_Model_Session /checkout/cart/ Mage_Core_Model_Session /checkout/onepage/saveOrder/… Mage_Rss_Model_Session /customer/account/loginPost/ Mage_Core_Model_Session …

2
Magento 2:以编程方式添加/删除产品图片的最佳做法?
我想将图像上传到现有产品。图像在中import_dir。并且需要将它们添加到目录中已经存在的产品中。 我只能找到两种方法。 1.“不良实践”方式-使用产品模型\Magento\Catalog\Model\Product::addImageToMediaGallery 1. Copy the images from `import_dir` to `pub/media/tmp` 2. Add the images to the product 3. Save product 码 /* copy files from import_dir to pub/media/tmp */ /** @var \Magento\Catalog\Api\Data\ProductInterface $product */ /* Init media gallery */ $mediaGalleryEntries = $product->getMediaGalleryEntries(); if (empty($mediaGalleryEntries) === true){ $product->setMediaGalleryEntries([]); } /* …

2
什么是硬依赖性,什么是软依赖性?
在Magento 2(任何稳定的版本)中,您可以运行此命令,bin/magento info:dependencies:show-modules并且您将在应用程序的根目录中获得一个csv文件,该文件modules-dependencies.csv带有如下所示的所有模块依赖项: 什么是硬依赖性,什么是软依赖性?每个示例都有帮助。

3
更改签出步骤时,属性在类Magento \ Quote \ Api \ Data \ AddressInterface中没有相应的setter
1-我将eav属性添加到customer_address $attributesInfo = [ 'reference' => [ 'label' => 'Reference', 'type' => 'varchar', 'input' => 'text', 'position' => 100, 'visible' => true, 'required' => false, ], ]; foreach ($attributesInfo as $attributeCode => $attributeParams) { $customerSetup->addAttribute('customer_address', $attributeCode, $attributeParams); } 2-我在模块中添加了extension属性 <extension_attributes for="Magento\Quote\Api\Data\AddressInterface"> <attribute code="reference" type="string"/> </extension_attributes> 在我的requirejs-config.js中,我覆盖了一些JavaScript文件以添加参考字段 var config = { …

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.