Skip to content
This repository has been archived by the owner on Oct 19, 2022. It is now read-only.

Commit

Permalink
Merge pull request #45 from EmicoEcommerce/merge/mprove-performance-o…
Browse files Browse the repository at this point in the history
…f-rel-no-follow-generation-in-attributes-template

Merge/mprove performance of rel no follow generation in attributes template
  • Loading branch information
edwinljacobs authored Jun 4, 2019
2 parents b63e4b7 + accddb3 commit 173dac2
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 13 deletions.
12 changes: 7 additions & 5 deletions app/code/community/Emico/Tweakwise/Helper/Seo.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ protected function exceedsAttributeLimit(Emico_Tweakwise_Model_Bus_Type_Facet $f

$selectedAttributes = $layer->getSelectedAttributes();
$selectedAttributesCount = count($selectedAttributes);
if ($facetLinkedTo !== null && !in_array($facetLinkedTo, $layer->getSelectedFacets())) {
if ($facetLinkedTo !== null) {
$selectedAttributesCount++;
}

Expand All @@ -60,16 +60,17 @@ protected function exceedsAttributeLimit(Emico_Tweakwise_Model_Bus_Type_Facet $f
/**
* Check if the given facet is not in the blacklist for indexing by robots
*
* @param Emico_Tweakwise_Model_Bus_Type_Facet|null $facetLinkedTo
* @return bool
*/
protected function isInFacetBlacklist(Emico_Tweakwise_Model_Bus_Type_Facet $facetLinkedTo = null)
{
$noFollowFacets = array_filter(explode(',', Mage::getStoreConfig('emico_tweakwise/navigation/nofollow_facets')));
if ($facetLinkedTo !== null && in_array($facetLinkedTo->getFacetSettings()->getUrlKey(), $noFollowFacets, true)) {
return true;
}
$layer = Mage::getSingleton('emico_tweakwise/catalog_layer');
$noFollowFacets = explode(',', Mage::getStoreConfig('emico_tweakwise/navigation/nofollow_facets'));
$selectedFacets = $layer->getSelectedFacets();
if ($facetLinkedTo !== null && !in_array($facetLinkedTo, $selectedFacets)) {
$selectedFacets[] = $facetLinkedTo;
}

foreach ($selectedFacets as $facet) {
$attributeCode = $facet->getFacetSettings()->getAttributeName();
Expand All @@ -90,6 +91,7 @@ protected function isInFacetBlacklist(Emico_Tweakwise_Model_Bus_Type_Facet $face
/**
* Check if the combination of 2 filters is allowed for indexing
*
* @param Emico_Tweakwise_Model_Bus_Type_Facet|null $facetLinkedTo
* @return bool
*/
protected function isInCombinationWhitelist(Emico_Tweakwise_Model_Bus_Type_Facet $facetLinkedTo = null)
Expand Down
20 changes: 14 additions & 6 deletions app/code/community/Emico/Tweakwise/Model/Catalog/Layer.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ class Emico_Tweakwise_Model_Catalog_Layer
*/
protected $_templateId;

/**
* @var array
*/
protected $_selectedFacets;

/**
* @return Mage_Catalog_Model_Product[]|Mage_Catalog_Model_Resource_Product_Collection
*/
Expand Down Expand Up @@ -350,15 +355,18 @@ public function getSelectedAttributes()
*/
public function getSelectedFacets()
{
$selectedFacets = [];
foreach ($this->getFacets() as $facet) {
foreach ($facet->getAttributes() as $attribute) {
if ($attribute->getIsSelected()) {
$selectedFacets[$facet->getFacetSettings()->getFacetId()] = $facet;
if ($this->_selectedFacets === null) {
$this->_selectedFacets = [];
foreach ($this->getFacets() as $facet) {
foreach ($facet->getAttributes() as $attribute) {
if ($attribute->getIsSelected()) {
$this->_selectedFacets[$facet->getFacetSettings()->getFacetId()] = $facet;
}
}
}
}
return $selectedFacets;

return $this->_selectedFacets;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@ public function buildCanonicalUrl(Emico_Tweakwise_Model_Catalog_Layer $state)

/**
* @param Emico_Tweakwise_Model_Catalog_Layer $state
* @return string
*/
protected function buildIndexableAttributePath(Emico_Tweakwise_Model_Catalog_Layer $state)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
<span class="helptext"><?php echo $this->__($_settings->getInfoText()); ?></span>
<?php endif; ?>


<?php $_attributes = $this->getAttributes(); ?>
<?php $_hrefAttributes = $this->getHrefAttributes(); ?>
<?php $_numberOfShownAttributes = 0; ?>

<ol <?php if ($this->hasAlternateSort()):?> data-has-alternate-sort="1"<?php endif;?>>
<?php foreach ($_attributes as $_index => $_item): ?>
<?php $_showLink = !$_item->getIsSelected() || $this->isCheckbox(); ?>
Expand All @@ -26,7 +27,7 @@
data-alternate-sort="<?=$_item->getAlternateSortOrder()?>"
<?php endif;?>
>
<a<?php if($_showLink): ?> href="<?php echo $this->escapeUrl($this->getFacetUrl($_item)) ?>"<?php endif; ?> title="<?=$this->escapeHtml($this->getItemTitle($_item))?>"<?=$this->getHrefAttributes()?>>
<a<?php if($_showLink): ?> href="<?php echo $this->escapeUrl($this->getFacetUrl($_item)) ?>"<?php endif; ?> title="<?=$this->escapeHtml($this->getItemTitle($_item))?>"<?=$_hrefAttributes?>>
<?php echo $this->escapeHtml($this->getItemTitle($_item)); ?>
<?php if ($_settings->getIsNumberOfResultVisible()): ?>
(<?php echo $_item->getNumberOfResults() ?>)
Expand Down

0 comments on commit 173dac2

Please sign in to comment.