Skip to content

Commit 065dce9

Browse files
committed
Merge branch 'develop'
2 parents 76116cd + 97bbc40 commit 065dce9

File tree

86 files changed

+1161
-616
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+1161
-616
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
phpunit.xml
22
composer.lock
3+
wercker.env
4+
.wercker
35
/vendor/
46
.idea/

build/install-magento.sh

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
set -x
4+
echo memory_limit=-1 >> /usr/local/etc/php/php.ini
5+
git checkout -b tmp
6+
git add -A
7+
git commit --allow-empty -m "tmp"
8+
export MODULE_DIR=`pwd`
9+
export M2SETUP_DB_HOST=$MYSQL_CI_PORT_3306_TCP_ADDR
10+
export M2SETUP_DB_USER=root
11+
export M2SETUP_DB_PASSWORD=$MYSQL_CI_ENV_MYSQL_ROOT_PASSWORD
12+
export M2SETUP_DB_NAME=magento
13+
export M2SETUP_BASE_URL=http://m2.localhost:8000/
14+
export M2SETUP_ADMIN_FIRSTNAME=Admin
15+
export M2SETUP_ADMIN_LASTNAME=User
16+
17+
export M2SETUP_ADMIN_USER=magento2
18+
export M2SETUP_ADMIN_PASSWORD=magento2
19+
export M2SETUP_VERSION=$1
20+
export M2SETUP_USE_SAMPLE_DATA=false
21+
export M2SETUP_USE_ARCHIVE=true
22+
export COMPOSER_HOME=$WERCKER_CACHE_DIR/composer
23+
mysqladmin -u$M2SETUP_DB_USER -p"$M2SETUP_DB_PASSWORD" -h$M2SETUP_DB_HOST create $M2SETUP_DB_NAME
24+
/usr/local/bin/mage-setup
25+
cd /srv/www
26+
composer config http-basic.repo.magento.com $MAGENTO_REPO_PUBLIC_KEY $MAGENTO_REPO_PRIVATE_KEY
27+
composer config repositories.solr-module vcs $MODULE_DIR
28+
composer config repositories.solr-autosuggest vcs [email protected]:integer-net/solr-magento2-autosuggest.git
29+
composer config repositories.solr-base vcs [email protected]:integer-net/solr-base.git
30+
composer config repositories.solr-pro vcs [email protected]:integer-net/solr-pro.git
31+
sed -i -e 's/"psr-4": {/"psr-4": {\n "IntegerNet\\\\Solr\\\\": ["vendor\/integer-net\/solr-magento2\/main\/test\/unit", "vendor\/integer-net\/solr-magento2\/main\/test\/integration", "vendor\/integer-net\/solr-base\/test\/Solr" ],/g' composer.json
32+
composer config minimum-stability dev
33+
composer require integer-net/solr-magento2 dev-tmp --no-update
34+
composer require --dev tddwizard/magento2-fixtures 0.3.0 --no-update
35+
phpunit_version="$(composer info | grep "phpunit/phpunit " | awk '{ print $2 }')"
36+
phpunit_minimum="5.7.0"
37+
if [ "$(printf "$phpunit_minimum\n$phpunit_version" | sort -V | head -n1)" == "$phpunit_version" ] && [ "$phpunit_version" != "$phpunit_minimum" ]; then
38+
composer require --dev phpunit/phpunit ^5.7 --no-update
39+
fi
40+
41+
composer update
42+
sed -i -e "s/8983/$SOLR_CI_PORT_8983_TCP_PORT/g" vendor/integer-net/solr-magento2/main/test/integration/_files/solr_config.dist.php
43+
sed -i -e "s/localhost/$SOLR_CI_PORT_8983_TCP_ADDR/g" vendor/integer-net/solr-magento2/main/test/integration/_files/solr_config.dist.php
44+
sed -i -e "s/solr-magento2-tests/core0/g" vendor/integer-net/solr-magento2/main/test/integration/_files/solr_config.dist.php
45+
bin/magento module:enable IntegerNet_Solr
46+
bin/magento setup:upgrade

build/integration-tests.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
set -x
4+
export MODULE_DIR=`pwd`
5+
export M2SETUP_DB_HOST=$MYSQL_CI_PORT_3306_TCP_ADDR
6+
export M2SETUP_DB_USER=root
7+
export M2SETUP_DB_PASSWORD=$MYSQL_CI_ENV_MYSQL_ROOT_PASSWORD
8+
export TEST_DB_NAME=magento_integration_tests
9+
mysqladmin -u$M2SETUP_DB_USER -p"$M2SETUP_DB_PASSWORD" -h$M2SETUP_DB_HOST create $TEST_DB_NAME
10+
cp $MODULE_DIR/main/test/integration/phpunit.xml.dist /srv/www/dev/tests/integration/phpunit.xml
11+
cp $MODULE_DIR/main/test/integration/install-config-mysql.php /srv/www/dev/tests/integration/etc/
12+
sed -i -e "s/DB_HOST/$M2SETUP_DB_HOST/g" /srv/www/dev/tests/integration/etc/install-config-mysql.php
13+
sed -i -e "s/DB_USER/$M2SETUP_DB_USER/g" /srv/www/dev/tests/integration/etc/install-config-mysql.php
14+
sed -i -e "s/DB_PASSWORD/$M2SETUP_DB_PASSWORD/g" /srv/www/dev/tests/integration/etc/install-config-mysql.php
15+
sed -i -e "s/DB_NAME/$TEST_DB_NAME/g" /srv/www/dev/tests/integration/etc/install-config-mysql.php
16+
cd /srv/www/dev/tests/integration
17+
php ../../../vendor/phpunit/phpunit/phpunit
18+
19+
cp $MODULE_DIR/categories/test/integration/phpunit.xml.dist /srv/www/dev/tests/integration/phpunit.xml
20+
cd /srv/www/dev/tests/integration
21+
php ../../../vendor/phpunit/phpunit/phpunit

categories/src/Block/Result/Categories.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,31 +10,32 @@
1010
namespace IntegerNet\SolrCategories\Block\Result;
1111

1212
use IntegerNet\SolrCategories\Model\ResourceModel\CategoriesCollection;
13+
use IntegerNet\SolrCategories\Model\ResourceModel\CategoriesCollectionFactory;
1314
use Magento\Catalog\Block\Product\Context;
1415

1516
class Categories extends \Magento\Catalog\Block\Product\AbstractProduct
1617
{
1718
/**
18-
* @var CategoriesCollection
19+
* @var CategoriesCollectionFactory
1920
*/
20-
private $categoriesCollection;
21+
private $categoriesCollectionFactory;
2122

2223
public function __construct(
2324
Context $context,
24-
CategoriesCollection $categoriesCollection,
25+
CategoriesCollectionFactory $categoriesCollectionFactory,
2526
array $data
2627
)
2728
{
2829
parent::__construct($context, $data);
29-
$this->categoriesCollection = $categoriesCollection;
30+
$this->categoriesCollectionFactory = $categoriesCollectionFactory;
3031
}
3132

3233
/**
3334
* @return CategoriesCollection
3435
*/
3536
public function getResultsCollection()
3637
{
37-
return $this->categoriesCollection;
38+
return $this->categoriesCollectionFactory->create();
3839
}
3940

4041
/**

categories/src/Setup/UpgradeData.php

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
<?php
2+
/**
3+
* integer_net Magento Module
4+
*
5+
* @category IntegerNet
6+
* @package IntegerNet_Solr
7+
* @copyright Copyright (c) 2017 integer_net GmbH (http://www.integer-net.de/)
8+
* @author Andreas von Studnitz <[email protected]>
9+
*/
10+
namespace IntegerNet\SolrCategories\Setup;
11+
12+
use Magento\Catalog\Model\Category;
13+
use Magento\Eav\Setup\EavSetup;
14+
use Magento\Eav\Setup\EavSetupFactory;
15+
use Magento\Framework\Setup\UpgradeDataInterface;
16+
use Magento\Framework\Setup\ModuleContextInterface;
17+
use Magento\Framework\Setup\ModuleDataSetupInterface;
18+
19+
class UpgradeData implements UpgradeDataInterface
20+
{
21+
/**
22+
* EAV setup factory
23+
*
24+
* @var EavSetupFactory
25+
*/
26+
private $eavSetupFactory;
27+
28+
/**
29+
* Init
30+
*
31+
* @param EavSetupFactory $eavSetupFactory
32+
*/
33+
public function __construct(EavSetupFactory $eavSetupFactory)
34+
{
35+
$this->eavSetupFactory = $eavSetupFactory;
36+
}
37+
38+
/**
39+
* Upgrades data for a module
40+
*
41+
* @param ModuleDataSetupInterface $setup
42+
* @param ModuleContextInterface $context
43+
* @return void
44+
*/
45+
public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
46+
{
47+
$setup->startSetup();
48+
49+
/** @var EavSetup $eavSetup */
50+
$eavSetup = $this->eavSetupFactory->create(['setup' => $setup]);
51+
52+
if (version_compare($context->getVersion(), '1.2.0', '<')) {
53+
54+
$this->addSolrBoostCategoryAttribute($eavSetup);
55+
}
56+
57+
$setup->endSetup();
58+
}
59+
60+
/**
61+
* @param EavSetup $eavSetup
62+
*/
63+
private function addSolrBoostCategoryAttribute(EavSetup $eavSetup)
64+
{
65+
$eavSetup->addAttribute(
66+
Category::ENTITY,
67+
'solr_boost',
68+
[
69+
'type' => 'decimal',
70+
'input' => 'text',
71+
'label' => 'Solr Priority',
72+
'frontend_class' => 'validate-number',
73+
'note' => '1 is default, use higher numbers for higher priority.',
74+
'required' => 0,
75+
'user_defined' => 0,
76+
'group' => 'Solr',
77+
'global' => 0,
78+
'visible' => 1,
79+
'default' => 1,
80+
]
81+
);
82+
}
83+
}

categories/src/etc/module.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0"?>
22
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
3-
<module name="IntegerNet_SolrCategories" setup_version="1.1.0">
3+
<module name="IntegerNet_SolrCategories" setup_version="1.2.0">
44
<sequence>
55
<module name="IntegerNet_Solr"/>
66
</sequence>

0 commit comments

Comments
 (0)