Skip to content

Commit

Permalink
Merge branch 'release/1.2.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
therouv committed Oct 22, 2015
2 parents dbc55ad + b2f3610 commit 582617f
Show file tree
Hide file tree
Showing 24 changed files with 275 additions and 76 deletions.
19 changes: 17 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ The interface to set the rules is very similar to the one to create shopping car

Facts
-----
- Version: 1.2.0

- Version: 1.2.1
- [extension on GitHub](https://github.com/firegento/firegento-dynamiccategory)

The module adds a new section "Dynamic Category Product Relater" at the tab "Category Products" of categories in the backend.
Expand All @@ -17,6 +18,7 @@ If a rule should be defined according to a specific attribute, that attribute ne

Requirements
------------

- PHP >= 5.3.0

Compatibility
Expand Down Expand Up @@ -77,7 +79,9 @@ DELETE FROM eav_attribute WHERE attribute_code = 'dynamiccategory';

<a name="usage">
Usage
-----------
-----

### How to use in category management

The module adds a new section "Dynamic Category Product Relater" at the tab "Category Products" while reading or editing a category into the backend.
You can define rules for products to be included in the category.
Expand All @@ -88,12 +92,23 @@ To define a rule, click on the `+` button and add one or more attributes then fi

When you finished to define the rules, save the current category.

### How to setup an attribute to be available for Dynamic Category

If a rule should be defined according to a specific attribute, that attribute needs to be enabled for "Use for Promo Rule Conditions" in its attribute configuration (See Catalog > Attributes > YOUR ATTRIBUTE > Edit it).

![Attribute Edit](./docs/images/attribute-rule-promotion.png)


### Cronjob

By default, there is a cronjob which runs every morning at 2 a.m. to reindex all dynamic categories.

If you want to change this time, please go to *System > Configuration > Advanced > System > Dynamic Category* and
change the cron expression.

![System Config Cron Expr](./docs/images/system-config-cron-expr.png)


Support
-------
If you have any issues with this extension, open an issue on [GitHub](https://github.com/firegento/firegento-customer/issues).
Expand Down
Binary file added docs/images/system-config-cron-expr.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
* @copyright 2013 FireGento Team (http://www.firegento.com)
* @license http://opensource.org/licenses/gpl-3.0 GNU General Public License, version 3 (GPLv3)
*/

/**
* Condition block for category edit page
*
Expand Down Expand Up @@ -70,7 +71,7 @@ public function _prepareLayout()

// New child url
$newChildUrl = $this->getUrl(
'dynamiccategory/dynamic/newConditionHtml/form/dynamiccategory_conditions_fieldset'
'adminhtml/dynamic/newConditionHtml/form/dynamiccategory_conditions_fieldset'
);

// Fieldset renderer
Expand All @@ -86,9 +87,9 @@ public function _prepareLayout()

// Add new field to the fieldset
$fieldset->addField('conditions', 'text', array(
'name' => 'conditions',
'label' => $this->__('Conditions'),
'title' => $this->__('Conditions'),
'name' => 'conditions',
'label' => $this->__('Conditions'),
'title' => $this->__('Conditions'),
))->setRule($model)->setRenderer(Mage::getBlockSingleton('dynamiccategory/conditions'));

$this->setForm($form);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
* @copyright 2013 FireGento Team (http://www.firegento.com)
* @license http://opensource.org/licenses/gpl-3.0 GNU General Public License, version 3 (GPLv3)
*/

/**
* Renderer for the conditions
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
* @copyright 2013 FireGento Team (http://www.firegento.com)
* @license http://opensource.org/licenses/gpl-3.0 GNU General Public License, version 3 (GPLv3)
*/

/**
* Helper class for translations, etc.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,12 @@ class FireGento_DynamicCategory_Model_Cron
*/
public function updateCategories()
{
$indexer = Mage::getSingleton('index/indexer')->getProcessByCode('dynamiccategory');
if ($indexer) {
$indexer->reindexEverything();
/* @var $indexer Mage_Index_Model_Indexer */
$indexer = Mage::getSingleton('index/indexer');
/* @var $process Mage_Index_Model_Process */
$process = $indexer->getProcessByCode('dynamiccategory');
if ($process) {
$process->reindexEverything();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
* @copyright 2013 FireGento Team (http://www.firegento.com)
* @license http://opensource.org/licenses/gpl-3.0 GNU General Public License, version 3 (GPLv3)
*/

/**
* Rule Backend Model for the attribute
*
Expand Down Expand Up @@ -60,13 +61,16 @@ public function beforeSave($object)
return $this;
}

/**
* Always update the related products after save.
*
* @param Varien_Object $object Object Model
* @return FireGento_DynamicCategory_Model_Entity_Attribute_Backend_Rule Self.
*/
public function afterSave($object)
{
$object->setIsChangedProductList(true);

public function afterSave($object) {
$attrCode = $this->getAttribute()->getAttributeCode();

//Always update the related products after save.
//if ($object->getData($attrCode) != serialize($object->getOrigData($attrCode))) {
$object->setIsChangedProductList(true);
//}
return parent::afterSave($object);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
* @copyright 2013 FireGento Team (http://www.firegento.com)
* @license http://opensource.org/licenses/gpl-3.0 GNU General Public License, version 3 (GPLv3)
*/

/**
* Indexer model for the dynamic category rules
*
Expand All @@ -34,7 +35,7 @@ class FireGento_DynamicCategory_Model_Indexer_Rule
* @var array Index Entities
*/
protected $_matchedEntities = array(
Mage_Catalog_Model_Product::ENTITY => array(
Mage_Catalog_Model_Product::ENTITY => array(
Mage_Index_Model_Event::TYPE_SAVE,
Mage_Index_Model_Event::TYPE_MASS_ACTION
),
Expand Down Expand Up @@ -136,7 +137,7 @@ protected function _registerCatalogProductEvent(Mage_Index_Model_Event $event)
/* @var $actionObject Varien_Object */
$actionObject = $event->getDataObject();

$reindexData = array();
$reindexData = array();
$rebuildIndex = false;

// check changed websites
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
* @copyright 2013 FireGento Team (http://www.firegento.com)
* @license http://opensource.org/licenses/gpl-3.0 GNU General Public License, version 3 (GPLv3)
*/

/**
* Old Mysql4 Resource model
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
* @copyright 2013 FireGento Team (http://www.firegento.com)
* @license http://opensource.org/licenses/gpl-3.0 GNU General Public License, version 3 (GPLv3)
*/

/**
* Resource model for rule conditions.
*
Expand Down Expand Up @@ -65,16 +66,16 @@ public function getDynamicProductIdsByCategory($categoryId)
->where('category_id = ?', $categoryId)
->where('dynamic = ?', 1);

$this->_dynamicProductdIdsByCategory[$categoryId] = (array) $read->fetchCol($select);
$this->_dynamicProductdIdsByCategory[$categoryId] = (array)$read->fetchCol($select);
}

return $this->_dynamicProductdIdsByCategory[$categoryId];
}

/**
* Enter description here ...
* Updates category-product relation, called during reindexing
*
* @param Varien_Object $object Object to reindex
* @param FireGento_DynamicCategory_Model_Rule $object Rule to reindex
* @param null|int $storeId Store id for reindex
* @param array $categoryIds Category Ids to reindex
*/
Expand Down Expand Up @@ -138,7 +139,7 @@ protected function _saveCategories($productIds, $categoryId)
}

$data[] = array(
'category_id' => (int) $categoryId,
'category_id' => (int)$categoryId,
'product_id' => $productId,
'position' => 99,
'dynamic' => 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@
* @copyright 2013 FireGento Team (http://www.firegento.com)
* @license http://opensource.org/licenses/gpl-3.0 GNU General Public License, version 3 (GPLv3)
*/

/**
* Model for rule conditions.
* Model for rule conditions. Used as an indexer model
* @see FireGento_DynamicCategory_Model_Indexer_Rule::getIndexer()
*
* @method FireGento_DynamicCategory_Model_Resource_Rule getResource()
*
* @category FireGento
* @package FireGento_DynamicCategory
Expand Down Expand Up @@ -117,7 +121,8 @@ public function getMatchingProductIds()
$websiteIds = explode(',', $this->getWebsiteIds());

if ($websiteIds) {
$productCollection = clone Mage::getResourceModel('catalog/product_collection');
/* @var $productCollection Mage_Catalog_Model_Resource_Product_Collection */
$productCollection = Mage::getResourceModel('catalog/product_collection');
$productCollection->addWebsiteFilter($websiteIds);

$this->getConditions()->collectValidatedAttributes($productCollection);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
* @copyright 2013 FireGento Team (http://www.firegento.com)
* @license http://opensource.org/licenses/gpl-3.0 GNU General Public License, version 3 (GPLv3)
*/

/**
* Combine Condition Class
*
Expand All @@ -28,6 +29,57 @@
class FireGento_DynamicCategory_Model_Rule_Condition_Combine
extends Mage_CatalogRule_Model_Rule_Condition_Combine
{
/**
* @var array
*/
protected $_customFilterAttributes = array(
'type_id', 'created_at', 'updated_at'
);

/**
* Get inherited conditions selectors
*
* @return array
*/
public function getNewChildSelectOptions()
{
$productCondition = Mage::getModel('dynamiccategory/rule_condition_product');
$productAttributes = $productCondition->loadAttributeOptions()->getAttributeOption();

$attributes = array();
foreach ($productAttributes as $code => $label) {
// Use CatalogRule condition class by default
$class = 'catalogrule/rule_condition_product';

// Use DynamicCategory condition class for some attributes
if (in_array($code, $this->_customFilterAttributes)) {
$class = 'dynamiccategory/rule_condition_product';
}

$attributes[] = array(
'value' => $class . '|' . $code,
'label' => $label
);
}

$conditions = array(
array(
'value' => '',
'label' => Mage::helper('rule')->__('Please choose a condition to add...')
),
array(
'value' => 'catalogrule/rule_condition_combine',
'label' => Mage::helper('catalogrule')->__('Conditions Combination')
),
array(
'label' => Mage::helper('catalogrule')->__('Product Attribute'),
'value' => $attributes
),
);

return $conditions;
}

/**
* Returns the aggregator options
*
Expand Down
Loading

0 comments on commit 582617f

Please sign in to comment.