0
votes

For a project I built a custom products extension with multiple views (list, show, nav ... etc). The nav view is build right in the header and lists product categories, groups and the actual products.

Now there a way too many sql queries every time the page loads. My idea now is to select only a few necessary fields for the nav view, such as title, uid, group and category.

This is the navAction within the controller:

public function navAction() {
  $produktenav = $this->produktRepository->findProductTitles();
  $this->view->assign('produktenav', $produktenav);
}

This is the function 'findProductTitles' within the repository:

public function findProductTitles($uid) {
  $query = $this->createQuery();
  $query->statement('SELECT produktname,produktkategorie,produktgruppe,uid,pid,produktbild FROM tx_produkte_domain_model_produkt WHERE deleted = 0 AND hidden = 0');
  return $query->execute();
}

This works as expected for the navAction. The issue I'm having is that the showAction now also only displays the fields I'm accessing by the SQL statement.

Both plugins are on the same page with the following statements:

temp.productNav = USER
temp.productNav {
  userFunc = TYPO3\CMS\Extbase\Core\Bootstrap->run
  pluginName = Produktnav
  extensionName = Produkte
  vendorName = Siteway

  switchableControllerActions.Produkt.1 = nav

  features    < plugin.tx_produkte_produkte.features
  view        < plugin.tx_produkte_produkte.view
  persistence < plugin.tx_produkte_produkte.persistence
  settings    < plugin.tx_produkte_produkte.settings
}

temp.productDetail = USER
temp.productDetail {
  userFunc = TYPO3\CMS\Extbase\Core\Bootstrap->run
  pluginName = Produkte
  extensionName = Produkte
  vendorName = Siteway

  switchableControllerActions.Produkt.1 = show

  features    < plugin.tx_produkte_produkte.features
  view        < plugin.tx_produkte_produkte.view
  persistence < plugin.tx_produkte_produkte.persistence
  settings    < plugin.tx_produkte_produkte.settings
}

My question here is: why is the showAction not ignoring the navAction statements? And how can I use both plugins on the same page?

The output for "produkte" should not be empty at any point. For some reason, only the data I require by sql (for navAction) are visible for the showAction.

Debug output

1

1 Answers

0
votes

My working example (ts setup) for using both plugins on the same page:

# global extension settings
plugin.tx_magshop {
  settings {
    ...
  }
}

# prepare plugin object
temp.extMagShop = USER
temp.extMagShop {
  userFunc = TYPO3\CMS\Extbase\Core\Bootstrap->run
  vendorName = Magnetica
  extensionName = MagShop
  pluginName = Shop
  controller = Shop
  action =
  settings =< plugin.tx_magshop.settings
  persistence =< plugin.tx_magshop.persistence
  view =< plugin.tx_magshop.view
}

# use prepared object in fluidtemplate
page.10 = FLUIDTEMPLATE
page.10 {
  variables {
    # search products
    search < temp.extMagShop
    search {
      action = search
      switchableControllerActions {
        Shop { 
          1 = search
        }
      }
      mvc {
        callDefaultActionIfActionCantBeResolved = 1
      }
    }
    # basket infobox on top
    basket < temp.extMagShop
    basket {
      action = basketInfo
      switchableControllerActions {
        Shop { 
          1 = basketInfo
        }
      }
      mvc {
        callDefaultActionIfActionCantBeResolved = 1
      }
    }
  }
}