如何安装麦进斗magento2安装插件

的2社区版配备了支持,仅在MySQL的搜索引擎,但有些项目需要,以增加销售或转化率更好或更可调整的搜索引擎。在这种情况下,我们正在实施的Solr或Elasticsearch搜索引擎。
在这篇文章中,我们将创建一个框架代码或粗糙的例子介绍,使我们能够实现像Solr的或额外的Elasticsearch搜索引擎主要的类和方法。如果你把在Magento 2管理员一起来看看,你可以找到一个位置的搜索引擎配置:商店- &配置- &目录- &目录搜索和下拉“搜索引擎”。
在下拉列表中你会发现,你只有MySQL的引擎和我们的第一步将是在这个下拉列表中添加产生额外选项带有标签的“Solr”。所以,让我们开始。
按照往常一样,你需要创建一个Magento的2模块(我想你已经知道了这个过程,但如果你不这样做,你可以阅读教程在这里)。在etc文件夹你的模块,你需要创建下一个XML代码文件di.xml:
&type name="Magento\Search\Model\Adminhtml\System\Config\Source\Engine"&
&arguments&
&argument name="engines" xsi:type="array"&
&item name="solr" xsi:type="string"&Solr&/item&
&/argument&
&/arguments&
有了这个XML代码我们增加了一个新的选项与选项名称为“我们的下拉列表中的Solr&”。如果创建得当和清理Magento的缓存,你就可以看到它在下拉那里将是一个新的选项“Solr的”。如果你看到它那么就意味着你添加正确。
在下一步中,我们将与PHP类是负责索引数据进行搜索服务器启动。
首先,我们应该执行引擎类,放在di.xml下面的代码:
&type name="Magento\CatalogSearch\Model\ResourceModel\EngineProvider"&
&arguments&
&argument name="engines" xsi:type="array"&
&item name="solr" xsi:type="string"&Inchoo\Solr\Model\ResourceModel\Engine&/item&
&/argument&
&/arguments&
你可以看到,我们推出了我们自己的引擎类“&Inchoo \ Solr的\型号\ ResourceModel \引擎&”。引擎类负责准备数据它(Solr的服务器之前,最后一个端点)去我们indexerHandler课前和引擎类必须实现:\ Magento的\ CatalogSearch \型号\ ResourceModel \ EngineInterface。
接口类包含接下来的四个方法:-&processAttributeValue准备属性值在Solr的索引存储-&getAllowedVisibility检索当前发动机允许值的可见性-&allowAdvancedIndex定义,如果目前的搜索引擎支持先进的指标-&prepareEntityIndex准备数组索引由分隔粘字符串
这些方法是强制性的,在你的引擎类来实现。为了更好地理解,您可以检查/类似于MySQL的本机类的比较逻辑:Magento的\ CatalogSearch \型号\ ResourceModel \发动机。
我们的骨架类的例子如下:
namespace Inchoo\Solr\Model\ResourceModel;
use Magento\CatalogSearch\Model\ResourceModel\EngineInterface;
class Engine implements EngineInterface
protected $catalogProductVisibility;
private $indexScopeResolver;
public function __construct(
\Magento\Catalog\Model\Product\Visibility $catalogProductVisibility,
\Magento\Framework\Indexer\ScopeResolver\IndexScopeResolver $indexScopeResolver
$this-&catalogProductVisibility = $catalogProductVisibility;
$this-&indexScopeResolver = $indexScopeResolver;
public function getAllowedVisibility()
return $this-&catalogProductVisibility-&getVisibleInSiteIds();
public function allowAdvancedIndex()
return false;
public function processAttributeValue($attribute, $value)
return $value;
public function prepareEntityIndex($index, $separator = ' ')
return $index;
public function isAvailable()
return true;
下一步是名称为“创建indexerHandler&Inchoo \ Solr的\型号\索引器\ IndexerHandler有落实”&的Magento \框架\索引器\ SaveHandler \ IndexerInterface。对于IndexerHandler的实现,你应该在你的di.xml文件中添加下面的代码:
&type name="Magento\CatalogSearch\Model\Indexer\IndexerHandlerFactory"&
&arguments&
&argument name="handlers" xsi:type="array"&
&item name="solr" xsi:type="string"&Inchoo\Solr\Model\Indexer\IndexerHandler&/item&
&/argument&
&/arguments&
如果打开IndexerInterface你会看到四种方法,你必须实现:-&saveIndex实体数据添加到索引-&deleteIndex从索引中删除实体的数据-&cleanIndex从索引中删除所有数据-&isAvailable定义是否引擎可用(可以实现平给Solr服务器和检查直播)。
我们IndexerHandler骨架类的例子如下:
namespace Inchoo\Solr\Model\Indexer;
use Magento\Eav\Model\Config;
use Magento\Framework\App\ResourceConnection;
use Magento\Framework\DB\Adapter\AdapterInterface;
use Magento\Framework\Indexer\SaveHandler\IndexerInterface;
use Magento\Framework\Indexer\IndexStructureInterface;
use Magento\Framework\Search\Request\Dimension;
use Magento\Framework\Search\Request\IndexScopeResolverInterface;
use Magento\Framework\Indexer\SaveHandler\Batch;
use Magento\Framework\Indexer\ScopeResolver\IndexScopeResolver;
class IndexerHandler implements IndexerInterface
private $indexStructure;
private $data;
private $fields;
private $resource;
private $batch;
private $eavConfig;
private $batchSize;
private $indexScopeResolver;
public function __construct(
Batch $batch,
array $data,
$batchSize = 50
$this-&batch = $batch;
$this-&data = $data;
$this-&batchSize = $batchSize;
public function saveIndex($dimensions, \Traversable $documents)
foreach ($this-&batch-&getItems($documents, $this-&batchSize) as $batchDocuments) {
public function deleteIndex($dimensions, \Traversable $documents)
foreach ($this-&batch-&getItems($documents, $this-&batchSize) as $batchDocuments) {
public function cleanIndex($dimensions)
public function isAvailable()
return true;
在这些方法中,你应该实现Solr的PHP客户端将进入上市操作的Solr服务器。很多时候,采用的是日光浴PHP客户端。
有了这一步,我们与索引数据的过程中进行搜索服务器结束。
现在,你可以检查是你索引可以与下一个命令(前集搜索引擎SOLR在Magento管理):
php /bin/magento indexer:reindex catalogsearch_fulltext
在接下来的,最后一步,我们将解释如何实现对Magento的前端2新的搜索引擎。同时,我们必须修改di.xml并添加下面的代码:
&type name="Magento\Search\Model\AdapterFactory"&
&arguments&
&argument name="adapters" xsi:type="array"&
&item name="solr" xsi:type="string"&Inchoo\Solr\SearchAdapter\Adapter&/item&
&/argument&
&/arguments&
我们新的适配器类Inchoo \ Solr的\ SearchAdapter \适配器。适配器类应该实现&&的Magento \框架\搜索\ AdapterInterface。在我们的适配器,我们必须实现的方法查询&-这个方法接受查询请求和处理。看看我们的例子中,一切都将更加清晰。
namespace Inchoo\Solr\SearchAdapter;
use Magento\Framework\Search\AdapterInterface;
use Magento\Framework\Search\RequestInterface;
use Magento\Framework\Search\Response\QueryResponse;
use Inchoo\Solr\SearchAdapter\Aggregation\Builder;
class Adapter implements AdapterInterface
protected $responseFactory;
protected $connectionManager;
protected $aggregationBuilder;
public function __construct(
ResponseFactory $responseFactory,
Builder $aggregationBuilder,
ConnectionManager $connectionManager
$this-&responseFactory = $responseFactory;
$this-&aggregationBuilder = $aggregationBuilder;
$this-&connectionManager = $connectionManager;
* @param RequestInterface $request
* @return QueryResponse
public function query(RequestInterface $request)
$client = $this-&getConnection();
$documents = [];
$documents[1007] = array('entity_id'=&'1007', 'score'=&46.055);
$documents[1031] = array('entity_id'=&'1031', 'score'=&45.055);
$documents[1120] = array('entity_id'=&'1120', 'score'=&44.055);
$aggregations = $this-&aggregationBuilder-&build($request, $documents);
$response = [
'documents' =& $documents,
'aggregations' =& $aggregations,
return $this-&responseFactory-&create($response);
public function getConnection(){
return $this-&connectionManager-&getConnection();
在我们的演示适配器类,我们硬编码产物entity_ids:,1120年从我们的数据库产品标识,仅用于测试目的。如果你想更深入,我建议你检查逻辑MySQL的本地适配器如何工作的。
有了这个步骤中,我们结束我们的榜样。尽管事情似乎相当复杂,当你开始工作,一切都会好起来。我希望你会喜欢你的新的搜索引擎的编码磁2。
阅读(...) 评论()
Magento推荐: |
Magento学习博客:
友情链接:Magento是一套专业开源的PHP电子商务系统。Magento设计得非常灵活,具有模块化架构体系和丰富的功能。易于与第三方应用系统无缝集成。Magento(麦进斗) 1.8.1.0
相关合集:
相关热搜:
大乱斗(Chaos Faction)是款英文版本的动作小游戏,进入游戏可以选择人物和喜欢的场景开始格斗,然后可以选关,进入战斗状态之后你可以吃到一些道具。进入游戏可以选择人物和喜欢的场景开始格斗,然后可以选关,进入战斗状态之后你可以吃到一些道具,游戏中随机会出现的武器,血药,防御等。...
高速下载地址
联通下载地址
电信下载地址
移动及其他下载地址
(您的评论需要经过审核才能显示)
我觉得现在的Magento(麦进斗)已经够我用得了,什么时候想换口味了,就试试免费软件的版本
之前找了其他的与这个Magento(麦进斗)类似的软件,唯独这个满意,而且还是免费软件
这个Magento(麦进斗)我已经安装了,用起来感觉不错,感谢分享!
实在没想到Magento(麦进斗)现在已经优化到15.2MB了,技术的确厉害
国产软件的Magento(麦进斗)就是好用,有机会体验下其它类型的
好极了,这个Magento(麦进斗)是我用过最好的PHP源码了
讲真,PHP源码里我只服Magento(麦进斗),不解释
感觉比Magento(麦进斗)上一个版本好用,简体中文版免费软件
不错,比有些PHP源码强多了,非常简单实用!
Magento(麦进斗)虽然是免费软件的,但还是有些问题,有待改进呀~
热门关键词从你的本地/开发/分期到实时迁移/生产始终是具有挑战性的。在Magento方面你必须要非常小心。
Magento的很重的系统。首先确定你的虚拟主机提供商符合标准的Magento&是什么Magento的运行2.0的硬件要求?
对于部署,您可以按照下面的教程,例如
移动Magento的2到本地系统
我认为,这需要停机时间。为了优化对活下来的时间我有如下建议。
在生产服务器,使子域(/magento或),承载您的整个Magento的2网站那边,导入您的数据库,以及。请确保您的主机上的根,在当前的直播网站托管。做测试和检查,您的网站是在上述领域做工精细。
向下当前实时网站。然后,当你必须让我们的Magento的网站当中,请使用DB,htaccess的结算缓存和索引为域名的开关。
让乌尔Magento的网站直播服务器上已经准备好了,才去住。为了优化停机时间
希望它帮助。建议表示欢迎。
阅读(...) 评论()
Magento推荐: |
Magento学习博客:
友情链接:福步外贸论坛(FOB Business Forum) |中国第一外贸论坛
对不起,您的 IP 地址不在被允许的范围内,,截图拷贝相关IP后发送邮件给
当前时区 GMT+8, 现在时间是
Powered by D1scuz! && 2001-

我要回帖

更多关于 麦进斗怎么安装 的文章

 

随机推荐