Skip to content

Commit

Permalink
Merge pull request #67 from magento-dragons/S60
Browse files Browse the repository at this point in the history
[Dragon] - S60
  • Loading branch information
iminiailo committed Jan 28, 2015
2 parents c67bf2c + 6c33550 commit 7541ee0
Show file tree
Hide file tree
Showing 154 changed files with 8,508 additions and 4,099 deletions.
323 changes: 193 additions & 130 deletions app/code/Magento/Bundle/Block/Catalog/Product/View/Type/Bundle.php

Large diffs are not rendered by default.

513 changes: 334 additions & 179 deletions app/code/Magento/Bundle/Model/Product/Type.php

Large diffs are not rendered by default.

8 changes: 0 additions & 8 deletions app/code/Magento/Catalog/Api/Data/EavAttributeInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ interface EavAttributeInterface extends \Magento\Eav\Api\Data\AttributeInterface

const APPLY_TO = 'apply_to';

const IS_CONFIGURABLE = 'is_configurable';

const IS_SEARCHABLE = 'is_searchable';

const IS_VISIBLE_IN_ADVANCED_SEARCH = 'is_visible_in_advanced_search';
Expand Down Expand Up @@ -95,12 +93,6 @@ public function getPosition();
*/
public function getApplyTo();

/**
* Whether the attribute can be used for configurable products
*
* @return string|null
*/
public function getIsConfigurable();
/**
* Whether the attribute can be used in Quick Search
*
Expand Down
10 changes: 0 additions & 10 deletions app/code/Magento/Catalog/Api/Data/ProductAttributeDataBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,16 +118,6 @@ public function setApplyTo($applyTo)
return $this;
}

/**
* @param string|null $isConfigurable
* @return $this
*/
public function setIsConfigurable($isConfigurable)
{
$this->_set('is_configurable', $isConfigurable);
return $this;
}

/**
* @param string|null $isSearchable
* @return $this
Expand Down
8 changes: 0 additions & 8 deletions app/code/Magento/Catalog/Model/Category/Attribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,6 @@ public function getIsSearchable()
return $this->getData(self::IS_SEARCHABLE);
}

/**
* {@inheritdoc}
*/
public function getIsConfigurable()
{
return $this->getData(self::IS_CONFIGURABLE);
}

/**
* {@inheritdoc}
*/
Expand Down
26 changes: 16 additions & 10 deletions app/code/Magento/Catalog/Model/Resource/Category.php
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,8 @@ public function deleteChildren(\Magento\Framework\Object $object)
*
* @param \Magento\Framework\Object $object
* @return $this
* @SuppressWarnings(PHPMD.NPathComplexity)
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
protected function _beforeSave(\Magento\Framework\Object $object)
{
Expand All @@ -231,23 +233,27 @@ protected function _beforeSave(\Magento\Framework\Object $object)
if (!$object->getChildrenCount()) {
$object->setChildrenCount(0);
}
if ($object->getLevel() === null) {
$object->setLevel(1);
}

if (!$object->getId()) {
if ($object->isObjectNew()) {
if (is_null($object->getPosition())) {
$object->setPosition($this->_getMaxPosition($object->getPath()) + 1);
}
$path = explode('/', $object->getPath());
$level = count($path);
$object->setLevel($level);
if ($level) {
$level = count($path) - ($object->getId() ? 1 : 0);
$toUpdateChild = array_diff($path, [$object->getId()]);

if (!$object->hasPosition()) {
$object->setPosition($this->_getMaxPosition(implode('/', $toUpdateChild)) + 1);
}
if (!$object->hasLevel()) {
$object->setLevel($level);
}
if (!$object->hasParentId() && $level) {
$object->setParentId($path[$level - 1]);
}
$object->setPath($object->getPath() . '/');

$toUpdateChild = explode('/', $object->getPath());
if (!$object->getId()) {
$object->setPath($object->getPath() . '/');
}

$this->_getWriteAdapter()->update(
$this->getEntityTable(),
Expand Down
8 changes: 0 additions & 8 deletions app/code/Magento/Catalog/Model/Resource/Eav/Attribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -544,14 +544,6 @@ public function getPosition()
return $this->getData(self::POSITION);
}

/**
* {@inheritdoc}
*/
public function getIsConfigurable()
{
return $this->getData(self::IS_CONFIGURABLE);
}

/**
* {@inheritdoc}
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
->load(1)
->setId(1)
->setStoreId(0)
->setPath(1)
->setPath('1')
->setLevel(0)
->setPosition(0)
->setChildrenCount(0)
Expand All @@ -26,11 +26,12 @@

$installer->createCategory()
->setStoreId(0)
->setPath('1')
->setName('Default Category')
->setDisplayMode('PRODUCTS')
->setAttributeSetId($category->getDefaultAttributeSetId())
->setIsActive(1)
->setPath('1')
->setLevel(1)
->setInitialSetupFlag(true)
->save();

Expand Down
12 changes: 1 addition & 11 deletions app/code/Magento/CatalogSearch/Block/Advanced/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function _prepareLayout()
*/
public function getSearchableAttributes()
{
$attributes = $this->getModel()->getAttributes();
$attributes = $this->_catalogSearchAdvanced->getAttributes();
return $attributes;
}

Expand Down Expand Up @@ -315,16 +315,6 @@ protected function _getDateBlock()
return $block;
}

/**
* Retrieve advanced search model object
*
* @return Advanced
*/
public function getModel()
{
return $this->_catalogSearchAdvanced;
}

/**
* Retrieve search form action url
*
Expand Down
29 changes: 14 additions & 15 deletions app/code/Magento/CatalogSearch/Model/Advanced.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
use Magento\Catalog\Model\Resource\Eav\Attribute;
use Magento\Catalog\Model\Resource\Product\Attribute\CollectionFactory;
use Magento\CatalogSearch\Model\Resource\Advanced\Collection;
use Magento\CatalogSearch\Model\Resource\EngineInterface;
use Magento\CatalogSearch\Model\Resource\EngineProvider;
use Magento\CatalogSearch\Model\Resource\ResourceProvider;
use Magento\Directory\Model\Currency;
use Magento\Directory\Model\CurrencyFactory;
use Magento\Eav\Model\Entity\Attribute as EntityAttribute;
Expand Down Expand Up @@ -53,13 +52,6 @@ class Advanced extends \Magento\Framework\Model\AbstractModel
*/
protected $_searchCriterias = [];

/**
* Current search engine
*
* @var EngineInterface
*/
protected $_engine;

/**
* Found products collection
*
Expand Down Expand Up @@ -109,6 +101,13 @@ class Advanced extends \Magento\Framework\Model\AbstractModel
*/
protected $_currencyFactory;

/**
* Resources factory
*
* @var ResourceProvider
*/
protected $_resourceProvider;

/**
* Construct
*
Expand All @@ -117,10 +116,10 @@ class Advanced extends \Magento\Framework\Model\AbstractModel
* @param CollectionFactory $attributeCollectionFactory
* @param Visibility $catalogProductVisibility
* @param Config $catalogConfig
* @param EngineProvider $engineProvider
* @param CurrencyFactory $currencyFactory
* @param ProductFactory $productFactory
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
* @param ResourceProvider $resourceProvider
* @param array $data
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
Expand All @@ -130,24 +129,24 @@ public function __construct(
CollectionFactory $attributeCollectionFactory,
Visibility $catalogProductVisibility,
Config $catalogConfig,
EngineProvider $engineProvider,
CurrencyFactory $currencyFactory,
ProductFactory $productFactory,
StoreManagerInterface $storeManager,
ResourceProvider $resourceProvider,
array $data = []
) {
$this->_attributeCollectionFactory = $attributeCollectionFactory;
$this->_catalogProductVisibility = $catalogProductVisibility;
$this->_catalogConfig = $catalogConfig;
$this->_engine = $engineProvider->get();
$this->_currencyFactory = $currencyFactory;
$this->_productFactory = $productFactory;
$this->_storeManager = $storeManager;
$this->_resourceProvider = $resourceProvider;
parent::__construct(
$context,
$registry,
$this->_engine->getResource(),
$this->_engine->getResourceCollection(),
$this->_resourceProvider->getResource(),
$this->_resourceProvider->getResourceCollection(),
$data
);
}
Expand Down Expand Up @@ -250,7 +249,7 @@ public function getAttributes()
public function getProductCollection()
{
if (is_null($this->_productCollection)) {
$collection = $this->_engine->getAdvancedResultCollection();
$collection = $this->_resourceProvider->getAdvancedResultCollection();
$this->prepareProductCollection($collection);
if (!$collection) {
return $collection;
Expand Down
68 changes: 0 additions & 68 deletions app/code/Magento/CatalogSearch/Model/Resource/Engine.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
*/
namespace Magento\CatalogSearch\Model\Resource;

use Magento\CatalogSearch\Model\Resource\Product\CollectionFactory;
use Magento\Framework\Model\Resource\Db\AbstractDb;

/**
Expand All @@ -24,30 +23,13 @@ class Engine extends AbstractDb implements EngineInterface
*/
protected $_catalogProductVisibility;

/**
* Product Collection Factory
*
* @var \Magento\CatalogSearch\Model\Resource\Product\CollectionFactory
*/
protected $productCollectionFactory;

/**
* Array of product collection factory names
*
* @var array
*/
protected $productFactoryNames;

/**
* @var \Magento\CatalogSearch\Model\Resource\Advanced
*/
protected $_searchResource;

/**
* @var \Magento\CatalogSearch\Model\Resource\Advanced\Collection
*/
protected $_searchResourceCollection;

/**
* Catalog search data
*
Expand All @@ -66,26 +48,20 @@ class Engine extends AbstractDb implements EngineInterface
* Construct
*
* @param \Magento\Framework\App\Resource $resource
* @param \Magento\CatalogSearch\Model\Resource\Product\CollectionFactory $productCollectionFactory
* @param \Magento\Catalog\Model\Product\Visibility $catalogProductVisibility
* @param \Magento\CatalogSearch\Model\Resource\Advanced $searchResource
* @param \Magento\CatalogSearch\Model\Resource\Advanced\Collection $searchResourceCollection
* @param \Magento\CatalogSearch\Helper\Data $catalogSearchData
* @param \Magento\Search\Model\Resource\Helper $resourceHelper
*/
public function __construct(
\Magento\Framework\App\Resource $resource,
CollectionFactory $productCollectionFactory,
\Magento\Catalog\Model\Product\Visibility $catalogProductVisibility,
\Magento\CatalogSearch\Model\Resource\Advanced $searchResource,
\Magento\CatalogSearch\Model\Resource\Advanced\Collection $searchResourceCollection,
\Magento\CatalogSearch\Helper\Data $catalogSearchData,
\Magento\Search\Model\Resource\Helper $resourceHelper
) {
$this->productCollectionFactory = $productCollectionFactory;
$this->_catalogProductVisibility = $catalogProductVisibility;
$this->_searchResource = $searchResource;
$this->_searchResourceCollection = $searchResourceCollection;
$this->_catalogSearchData = $catalogSearchData;
$this->_resourceHelper = $resourceHelper;
parent::__construct($resource);
Expand Down Expand Up @@ -243,50 +219,6 @@ public function prepareEntityIndex($index, $separator = ' ')
return $this->_catalogSearchData->prepareIndexdata($index, $separator);
}

/**
* Return resource model for the full text search
*
* @return \Magento\CatalogSearch\Model\Resource\Advanced
*/
public function getResource()
{
return $this->_searchResource;
}

/**
* Return resource collection model for the full text search
*
* @return \Magento\CatalogSearch\Model\Resource\Advanced\Collection
*/
public function getResourceCollection()
{
return $this->_searchResourceCollection;
}

/**
* Retrieve fulltext search result data collection
*
* @return \Magento\Catalog\Model\Resource\Product\Collection
*/
public function getResultCollection()
{
return $this->productCollectionFactory->create(
\Magento\CatalogSearch\Model\Resource\Product\CollectionFactory::PRODUCT_COLLECTION_FULLTEXT
);
}

/**
* Retrieve advanced search result data collection
*
* @return \Magento\Catalog\Model\Resource\Product\Collection
*/
public function getAdvancedResultCollection()
{
return $this->productCollectionFactory->create(
\Magento\CatalogSearch\Model\Resource\Product\CollectionFactory::PRODUCT_COLLECTION_ADVANCED
);
}

/**
* Define if Layered Navigation is allowed
*
Expand Down
Loading

0 comments on commit 7541ee0

Please sign in to comment.