Skip to content

Commit

Permalink
Merge branch 'release/1.97.25'
Browse files Browse the repository at this point in the history
  • Loading branch information
ktomk committed Dec 6, 2016
2 parents 82fa579 + 03cd1de commit 66cadf1
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 18 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
RECENT CHANGES
==============

1.97.25
-------
* Fix: Add missing new commands to config.yaml (by Giuseppe Morelli, #877)

1.97.24
-------
* Fix: Array to string conversion notice (report by Christian Münch, fix by Tom Klingenberg)
Expand Down
2 changes: 2 additions & 0 deletions config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ commands:
- N98\Magento\Command\Cache\ListCommand
- N98\Magento\Command\Cache\ReportCommand
- N98\Magento\Command\Cache\ViewCommand
- N98\Magento\Command\Category\Create\DummyCommand
- N98\Magento\Command\Cms\Banner\ToggleCommand
- N98\Magento\Command\Cms\Block\ToggleCommand
- N98\Magento\Command\Cms\Page\PublishCommand
Expand Down Expand Up @@ -118,6 +119,7 @@ commands:
- N98\Magento\Command\Developer\Translate\InlineShopCommand
- N98\Magento\Command\Developer\Translate\SetCommand
- N98\Magento\Command\Developer\Translate\ExportCommand
- N98\Magento\Command\Eav\Attribute\Create\DummyCommand
- N98\Magento\Command\Eav\Attribute\ListCommand
- N98\Magento\Command\Eav\Attribute\RemoveCommand
- N98\Magento\Command\Eav\Attribute\ViewCommand
Expand Down
2 changes: 1 addition & 1 deletion src/N98/Magento/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class Application extends BaseApplication
/**
* @var string
*/
const APP_VERSION = '1.97.24';
const APP_VERSION = '1.97.25';

/**
* @var int
Expand Down
41 changes: 25 additions & 16 deletions src/N98/Magento/Command/Category/Create/DummyCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace N98\Magento\Command\Category\Create;

use Mage;
use Mage_Catalog_Model_Category;
use RuntimeException;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
Expand Down Expand Up @@ -74,24 +75,21 @@ protected function execute(InputInterface $input, OutputInterface $output)
}
unset($collection);

$_category_root_id = Mage::app()->getStore($_argument['store-id'])->getRootCategoryId();
$storeId = $_argument['store-id'];
$rootCategoryId = Mage::app()->getStore($storeId)->getRootCategoryId();

/* @var $category Mage_Catalog_Model_Category */
$category = Mage::getModel('catalog/category');
$category->setName($name);
$category->setIsActive(self::DEFAULT_CATEGORY_STATUS);
$category->setDisplayMode('PRODUCTS');
$category->setIsAnchor(self::DEFAULT_CATEGORY_ANCHOR);

if (Mage::getVersion() === "1.5.1.0") {
$category->setStoreId(array(0, $_argument['store-id']));
} else {
$category->setStoreId($_argument['store-id']);
}
$parentCategory = Mage::getModel('catalog/category')->load($_category_root_id);
$this->setCategoryStoreId($category, $storeId);
$parentCategory = Mage::getModel('catalog/category')->load($rootCategoryId);
$category->setPath($parentCategory->getPath());

$category->save();
$_parent_id = $category->getId();
$parentCategoryId = $category->getId();
$output->writeln(
"<comment>CATEGORY: '" . $category->getName() . "' WITH ID: '" . $category->getId() .
"' CREATED!</comment>"
Expand All @@ -102,18 +100,14 @@ protected function execute(InputInterface $input, OutputInterface $output)
for ($j = 0; $j < $_argument['children-categories-number']; $j++) {
$name_child = $name . " child " . $j;

/* @var $category Mage_Catalog_Model_Category */
$category = Mage::getModel('catalog/category');
$category->setName($name_child);
$category->setIsActive(self::DEFAULT_CATEGORY_STATUS);
$category->setDisplayMode('PRODUCTS');
$category->setIsAnchor(self::DEFAULT_CATEGORY_ANCHOR);

if (Mage::getVersion() === "1.5.1.0") {
$category->setStoreId(array(0, $_argument['store-id']));
} else {
$category->setStoreId($_argument['store-id']);
}
$parentCategory = Mage::getModel('catalog/category')->load($_parent_id);
$this->setCategoryStoreId($category, $storeId);
$parentCategory = Mage::getModel('catalog/category')->load($parentCategoryId);
$category->setPath($parentCategory->getPath());

$category->save();
Expand Down Expand Up @@ -216,4 +210,19 @@ private function askForArguments($input, $output)

return $_argument;
}

/**
* Setting the store-ID of a category requires a compatibility layer for Magento 1.5.1.0
*
* @param Mage_Catalog_Model_Category $category
* @param string|int $storeId
*/
private function setCategoryStoreId(Mage_Catalog_Model_Category $category, $storeId)
{
if (Mage::getVersion() === "1.5.1.0") {
$category->setStoreId(array(0, $storeId));
} else {
$category->setStoreId($storeId);
}
}
}
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.97.24
1.97.25

0 comments on commit 66cadf1

Please sign in to comment.