Skip to content

Port for Magento 2 DEV BETA #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions app/code/RicoNeitzel/VertNav/Block/Navigation.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* @copyright Copyright (c) 2011 Vinai Kopp http://netzarbeiter.com/
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/

namespace RicoNeitzel\VertNav\Block;

/**
* Catalog vertical navigation
Expand All @@ -27,7 +27,7 @@
* @package RicoNeitzel_VertNav
* @author Vinai Kopp <vinai@netzarbeiter.com>
*/
class RicoNeitzel_VertNav_Block_Navigation extends \Magento\Catalog\Block\Navigation
class Navigation extends \Magento\Catalog\Block\Navigation
{
/**
* @var \Magento\Customer\Model\Session
Expand Down Expand Up @@ -100,10 +100,14 @@ public function __construct(
public function getCacheKey()
{
$key = parent::getCacheKey();

$customerGroupId = $this->_getCustomerGroupId();
$productId = $this->_registry->registry('current_product') ? $this->_registry->registry('current_product')->getId() : 0;
$homePageId = $this->_getStoreConfigValue(\Magento\Cms\Helper\Page::XML_PATH_HOME_PAGE);
$cmsPageId = $this->getRequest()->getParam('page_id', $homePageId);

/** @var \Magento\Catalog\Model\Product $currentProduct */
$currentProduct = $this->_registry->registry('current_product');
$productId = $currentProduct ? $currentProduct->getId() : 0;
$homePageId = $this->_getStoreConfigValue(\Magento\Cms\Helper\Page::XML_PATH_HOME_PAGE);
$cmsPageId = $this->getRequest()->getParam('page_id', $homePageId);

return 'VERTNAV_' . $key . '_' . $customerGroupId . '_' . $productId . '_' . $cmsPageId;
}
Expand Down Expand Up @@ -429,12 +433,13 @@ public function getStoreCategories()
}

/**
* $childrenIdString is a comma seperated list of category IDs
* $childrenIdString is a comma separated list of category IDs
* @return \Magento\Catalog\Model\Resource\Category\Collection
*/
protected function _getCategoryCollection()
{
$collection = $this->_categoryCollectionFactory->create();

/* @var $collection \Magento\Catalog\Model\Resource\Category\Collection */
$collection->addAttributeToSelect('url_key')
->addAttributeToSelect('name')
Expand Down
20 changes: 11 additions & 9 deletions app/code/RicoNeitzel/VertNav/Block/Plugin/LoginCatalog.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/

namespace RicoNeitzel\VertNav\Block\Plugin;

/**
* Plugin that provides compatibility with Netzarbeiter_LoginCatalog extension
*/
class RicoNeitzel_VertNav_Block_Plugin_LoginCatalog
class LoginCatalog
{
/**
* @var \Magento\Framework\ObjectManager
* @var \Magento\Framework\App\ObjectManager
*/
protected $_objectManager;

Expand All @@ -40,12 +42,12 @@ class RicoNeitzel_VertNav_Block_Plugin_LoginCatalog
protected $_customerSession;

/**
* @param \Magento\Framework\ObjectManager $objectManager
* @param \Magento\Framework\App\ObjectManager $objectManager
* @param \Magento\Framework\Module\Manager $moduleManager
* @param \Magento\Customer\Model\Session $customerSession
*/
public function __construct(
\Magento\Framework\ObjectManager $objectManager,
\Magento\Framework\App\ObjectManager $objectManager,
\Magento\Framework\Module\Manager $moduleManager,
\Magento\Customer\Model\Session $customerSession
) {
Expand All @@ -57,7 +59,7 @@ public function __construct(
/**
* Suppress rendering according to Netzarbeiter_LoginCatalog's business logic
*
* @param RicoNeitzel_VertNav_Block_Navigation $subject
* @param \RicoNeitzel\VertNav\Block\Navigation $subject
* @param callable $proceed
* @param \Magento\Catalog\Model\Category $category
* @param integer $level
Expand All @@ -66,7 +68,7 @@ public function __construct(
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function aroundDrawOpenCategoryItem(
RicoNeitzel_VertNav_Block_Navigation $subject,
\RicoNeitzel\VertNav\Block\Navigation $subject,
\Closure $proceed,
$category,
$level = 0,
Expand All @@ -84,7 +86,7 @@ public function aroundDrawOpenCategoryItem(
*/
protected function _isLoginCatalogInstalledAndActive()
{
return $this->_moduleManager->isEnabled('Netzarbeiter_LoginCatalog');
return $this->_moduleManager->isEnabled('Netzarbeiter\LoginCatalog');
}

/**
Expand All @@ -93,8 +95,8 @@ protected function _isLoginCatalogInstalledAndActive()
*/
protected function _loginCatalogHideCategories()
{
/** @var Netzarbeiter_LoginCatalog_Helper_Data $loginCatalog */
$loginCatalog = $this->_objectManager->get('Netzarbeiter_LoginCatalog_Helper_Data');
/** @var \Netzarbeiter\LoginCatalog\Helper\Data $loginCatalog */
$loginCatalog = $this->_objectManager->get('Netzarbeiter\LoginCatalog\Helper\Data');
return !$this->_customerSession->isLoggedIn()
&& $loginCatalog->moduleActive()
&& $loginCatalog->getConfig('hide_categories');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/

class RicoNeitzel_VertNav_Model_System_Config_Source_Root
extends \Magento\Eav\Model\Entity\Attribute\Source\AbstractSource
namespace RicoNeitzel\VertNav\Model\System\Config\Source;

class Root extends \Magento\Eav\Model\Entity\Attribute\Source\AbstractSource
{
/**
* @var \Magento\Catalog\Model\Resource\Category
Expand Down Expand Up @@ -56,7 +57,7 @@ public function toOptionArray()
);
$resource = $this->_categoryResource;
$select = $resource->getReadConnection()->select()->reset()
->from($resource->getTable('catalog_category_entity'), new Zend_Db_Expr('MAX(`level`)'));
->from($resource->getTable('catalog_category_entity'), new \Zend_Db_Expr('MAX(`level`)'));
$maxDepth = $resource->getReadConnection()->fetchOne($select);
for ($i = 2; $i < $maxDepth; $i++) {
$options[] = array(
Expand Down
39 changes: 39 additions & 0 deletions app/code/RicoNeitzel/VertNav/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"name": "riconeitzel/vertical-navigation",
"type": "magento2-module",
"version": "0.42.0-beta1",
"license": [
"OSL-3.0",
"AFL-3.0"
],
"homepage": "https://github.com/riconeitzel/VertNav",
"description": "Vertical Navigation with CSS Classes.",
"authors": [
{
"name":"Rico Neitzel",
"email":"mail@riconeitzel.de"
},
{
"name":"Vinai Kopp",
"email":"vinai@netzarbeiter.com"
}
],
"require": {
"php": "~5.4.11|~5.5.0",
"magento/module-core": "0.42.0-beta1",
"magento/module-catalog": "0.42.0-beta1",
"magento/module-cms": "0.42.0-beta1",
"magento/module-customer": "0.42.0-beta1",
"magento/module-theme": "0.42.0-beta1",
"magento/framework": "0.42.0-beta1",
"magento/magento-composer-installer": "*"
},
"extra": {
"map": [
[
"*",
"RicoNeitzel/VertNav"
]
]
}
}
2 changes: 1 addition & 1 deletion app/code/RicoNeitzel/VertNav/etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
</field>
<field id="vertnav_root" translate="label" type="select" sortOrder="50" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Expand all categories</label>
<source_model>RicoNeitzel_VertNav_Model_System_Config_Source_Root</source_model>
<source_model>RicoNeitzel\VertNav\Model\System\Config\Source\Root</source_model>
</field>
<field id="fallback_to_root" translate="label comment" type="select" sortOrder="60" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Fallback to store base</label>
Expand Down
8 changes: 4 additions & 4 deletions app/code/RicoNeitzel/VertNav/etc/module.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/Magento/Framework/Module/etc/module.xsd">
<module name="RicoNeitzel_VertNav" version="2.0.0" active="true">
<depends>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd">
<module name="RicoNeitzel_VertNav" schema_version="2.0.0">
<sequence>
<module name="Magento_Core"/>
<module name="Magento_Catalog"/>
<module name="Magento_Cms"/>
<module name="Magento_Customer"/>
<module name="Magento_Eav"/>
<module name="Magento_Theme"/>
<!--<module name="Netzarbeiter_LoginCatalog"/>-->
</depends>
</sequence>
</module>
</config>
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
*/
-->
<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../Magento/Core/etc/layout_single.xsd">
<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/layout_generic.xsd">
<remove name="catalog.leftnav"/>
</layout>
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
*/
-->
<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../Magento/Core/etc/layout_single.xsd">
<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/layout_generic.xsd">
<referenceBlock name="catalog.leftnav">
<action method="unsetChild">
<argument name="name" xsi:type="string">category_filter</argument>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
*/
-->
<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../Magento/Core/etc/layout_single.xsd">
<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/layout_generic.xsd">
<remove name="catalog.vertnav"/>
</layout>
6 changes: 3 additions & 3 deletions app/code/RicoNeitzel/VertNav/view/frontend/layout/default.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
*/
-->
<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../Magento/Core/etc/layout_single.xsd">
<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/layout_generic.xsd">
<referenceBlock name="head">
<block class="Magento\Theme\Block\Html\Head\Css" name="riconeitzel-vertnav-style-css">
<arguments>
<argument name="file" xsi:type="string">RicoNeitzel_VertNav::style.css</argument>
<argument name="file" xsi:type="string">RicoNeitzel_VertNav::css/style.css</argument>
</arguments>
</block>
</referenceBlock>
Expand All @@ -39,6 +39,6 @@
</referenceContainer>

<referenceContainer name="left">
<block class="RicoNeitzel_VertNav_Block_Navigation" name="catalog.vertnav" template="RicoNeitzel_VertNav::left.phtml" ifconfig="catalog/vertnav/show_vertnav"/>
<block class="RicoNeitzel\VertNav\Block\Navigation" name="catalog.vertnav" template="RicoNeitzel_VertNav::left.phtml" ifconfig="catalog/vertnav/show_vertnav"/>
</referenceContainer>
</layout>
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
* @see RicoNeitzel_VertNav_Block_Navgation
* @see Mage_Catalog_Block_Navigation
*/

/** @var \Magento\Catalog\Model\Category $_category */
?>
<div class="vertnav-container">
<div class="">
Expand Down