How to display products from subcategory to parent category in opencart? - categories

I'm trying to find a solution but still no luck. I want to display all products from subcategories to parent category.
I'm using Opencart 1.5.3.1

After reading the source, I figured it out:
In catalog/controller/product/category.php (or wherever you're calling function model_catalog_product->getProducts) you have to add filter_sub_category = true:
$data = array(
'filter_category_id' => $top_category,
'filter_sub_category' => true,
'sort' => $sort,
'order' => $order,
'start' => ($page - 1) * $limit,
'limit' => $limit
);
$product_total = $this->model_catalog_product->getTotalProducts($data);
Make sure you check the other answers if you're using a later version ;)

Another solution, rather than modifying the core files directly, is to use vQmod to modify the file for you. That way when you upgrade to a new version, you won't have to re-install any custom modifications you've made.
Below is an the code you'd use to accomplish this in vQmod:
<?xml version="1.0" encoding="UTF-8"?>
<modification>
<id>Display products in sub-categories while browsing a parent category</id>
<version>1.0.0</version>
<vqmver>2.4.0</vqmver>
<author>Jay Williams - jay#myd3.com</author>
<file name="catalog/controller/product/category.php">
<operation>
<search position="after"><![CDATA['filter_category_id' => $category_id,]]></search>
<add><![CDATA['filter_sub_category' => true,]]></add>
</operation>
</file>
</modification>
Source: https://gist.github.com/jaywilliams/8044763

catalog/controller/product/category.php
For Opencart Version 2.1.0.2, the solution of Ignacio works fines as well just that:
$data (of version 1.5.x) is now called
$filter_data (line #169)
Then just add the line
'filter_sub_category' => true,
after line #170 ('filter_category_id' => $category_id,)
Thanks Ignacio!

the vqmod method is the best and works easily. just add that file and anything.xml and place it in vqmod > xml

Just contributing with one more information, newest versions uses "ocmod", OpenCart's own vqmod feature. It can work the same way through there.

For Opencart 3.x:
./catalog/controller/product/category.php
find:
'filter_category_id' => $category_id,
add after:
'filter_sub_category' => true,
After change file, go to "Modification" and "Clear" and "Update" button click

Related

TYPO3 - TCA Migrations - Informational or ToDo?

I'm a newbie in typo3. A friend of me asked, if I can upgrade his installation for him, because I'm a developer. So I checked if I can do it.
I did several steps to upgrade the installation from 7.6.9 to 8.7.3. Now I ended in the installation tool in the section important actions. There is a point TCA migrations.
There it says:
TCA migrations need to be applied Check the following list and apply
needed changes.
The icon path of wizard "link" from TCA table
"tx_myredirects_domain_model_redirect['columns']['destination']['config']['wizards']['link']['icon']"has
been migrated to
tx_myredirects_domain_model_redirect['columns']['destination']['config']['wizards']['link']['icon']"
= 'actions-wizard-link'. ...
Is this just informational or do I have to modify something in the things listed?
Sorry again, if this is a newbie question, but I am actually a newbie in typo3.
If the extensions that need to migrate the TCAs haven't been created by you, then no, you do not really need to change them. The author of the extension should do it, because if you change them and then the author releases an update, then all your changes will be lost.
If the extension is a custom extension, then it would be better to migrate them. Then you can avoid bugs and unwanted disfunctions.
If you have a sitepackage, you can override the TCA's and give them new definitions. This way, if the author releases an update, your TCAs won't be lost. In order to do that, you can follow these instructions:
Extending TCAs
An example would be:
your_sitepackage/Configuration/TCA/Overrides/tx_tablename_domain_model_modelname
$GLOBALS['TCA']['tx_tablename_domain_model_modelname']['columns']['columnYouNeedToChange'] = [
'label' => 'input_29 link',
'config' => [
'type' => 'input',
'wizards' => [
'link' => [
'type' => 'popup',
'title' => 'LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:header_link_formlabel',
'icon' => 'actions-wizard-link',
'module' => [
'name' => 'wizard_link',
],
'JSopenParams' => 'height=800,width=600,status=0,menubar=0,scrollbars=1',
'params' => [
'blindLinkOptions' => 'folder',
'blindLinkFields' => 'class, target',
'allowedExtensions' => 'jpg',
],
],
],
]
This for example would solve the first problem of the image you shared. You just need to replace the table name. (That's TYPO3v8. TYPO3 v9 has more changes when it comes to TCAs)
If you are not sure how the path to the column look like ($GLOBALS['TCA']['tx_tablename_domain_model_modelname']['columns']['columnYouNeedToChange']) then follow this:
TCA Paths
#Thomas Löffler is right. It would be very useful to create an issue on GitHub and let the author know that some changes need to be made.
Best regards
This will show which TCA fields have been identified to have a legacy format and have been transformed while loading the configuration files.
While it is good practice to do these changes and keep this clean, strictly speaking it is not required.
Tip: I would rather look there before an upgrade because deprecated stuff might still have an upgrade path in an older version but none in the newest.

How to manage different versions of application by using plugins in cakephp 3?

I have a single cakephp 3 application
I have a generic view which render data depending of an array struture of fields configured in each Model, this array includes configurations for display each field in the view like (text titles, maxsize, sortable, etc..) and database configuration like (column name in the database/table, datatype, etc..) in the same array, and its working fine.
public $tableData = [
[
'name' => 'Table1.name',
'title' => 'Name',
'field' => 'name',
'sortable' => true,
'type' => 'string',
'size' => '50px',
],
[
'name' => 'Asosiation1.option',
'title' => 'Topic',
'field' => 'topic_option',
'sortable' => true,
'type' => 'string',
'size' => '150px',
],
... More fields and asosiations
]
But now, i need to have these same Models in different versions, because the structure of the database/table for each Model change every year, but i need to preserv/show the data corresponding to each version as it is.
So if a user request mySite.com/2010, Site must show data using Model array structure defined for that year especifically.
So, i created:
/plugins/Years/version2010
/plugins/Years/version2011
etc..
and in each pluging, I copied all Models changing only the namespace, defaultConnectionName (1 schema per Year) and array structure.
This provokes to have mutiple plugins loaded in bootstrap config.
Is there any way to load only the necesary plugin depending of the request ?(/2010, /2011, etc..)
Ex. In bootstrap.php I do for each plugin year:
Plugin::load('Years/version201X', ['bootstrap' => false, 'routes' => true]);
also
Is there any way to avoid having to specify the plugin name every time i do loadModel() or TableRegistry::get() ?
Ex. In main App GeneralController I have to do every time:
$this->loadModel('Years/version201X/Table1');
Or maybe there is another better approach to solve this situation i havent seen
Is there any way to load only the necesary plugin depending of the
request ?(/2010, /2011, etc.
Yes. Inside config/bootstrap.php you can check the request uri and then have a switch statement for the plugins. Something like this:
$uri = filter_input(INPUT_SERVER, 'REQUEST_URI', FILTER_SANITIZE_SPECIAL_CHARS);
// might need explode('/', $uri); to extract the right URL component
switch ($uri) {
case '2011':
// load plugin
break;
case '2012':
// log plugin
break;
}
You probably dont even need the switch statement, be creative there. Obviously thats not exact, but if gives you the right idea.
Is there any way to avoid having to specify the plugin name every time
i do loadModel() or TableRegistry::get() ?
If the model is unique to the plugin then I am not sure how you get away with this. Whats the problem though? Just a few extra characters. Sounds like you only have to do this once per year, right? However, you might not have to specify that if you're within the scope of the plugin. I am not sure on that, but its worth trying.

Typo3 Realurl urlcache is messed up by gclid-parameter

We use Google-Adwords for some campaigns which ads a gclid=xxxxx parameter to the URL.
Unfortunately, this messes up the RealUrl tables and when the page is called next time it results in a 404-error.
Is there any way to make RealUrl ignore this particular parameter?
This is claimed to be solved on GitHub:
https://github.com/dmitryd/typo3-realurl/issues/377
Anyways I still had that problem that the gclid triggers a urldata entry which causes a redirect loop. For now I solved it with removing the gclid from the ignoredGetparameters Filter and then banning it:
'cache' => array( // removed gclid from the filter, then ban it
'ignoredGetParametersRegExp' => '/^(?:utm_[a-z]+|pk_campaign|pk_kwd|TSFE_ADMIN_PANEL.*)$/'
'banUrlsRegExp' => '/gclid|tx_solr|tx_indexed_search|(?:^|\?|&)q=/',
),
Go to the Install Tool and add the parameter to [FE][cHashExcludedParameters].
Since realurl 2, there is a new possibility to control entries to tx_realurl_urldata:
https://github.com/dmitryd/typo3-realurl/wiki/Configuration-reference#banurlsregexp
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl']['_DEFAULT'] = array(
//[...]
'cache' => array(
'banUrlsRegExp' => '/gclid|tx_solr|tx_indexed_search|(?:^|\?|&)q=/'
),
//[...]
Works like a charm, didn't knew until today this option even exists.

TYPO3 new record appearing on wrong location in Backend List

I'm developing a new extension using ExtBase in TYPO3 (4.7) for a client.
I have however the strangest problem. In the back-end, my possible, new record types are - as usual - listed in the Insert new record Backend List. Usually each of these record-types are preceded by the module name (actually they are grouped right after the module name).. However, in my case, 1 or 2 of the record-types of any other extension appear within my extension's list as well.. I've been trying to figure out pretty much all that I can, I even copied the extension over to an entirely different TYPO3 installation, but the same problem persists..
If of any extension some records appear just below my extension's title, and I delete that particular extension, just some other record-types appear of another extension.
What's going on here??
Short & late answer:
i guess you have defined the title of your models in two different ways or with a non-existent languagefile in your ext_tables.php. Something like this:
Model1:
$TCA['tx_aaext_domain_model_one'] = array(
'ctrl' => array(
'title' => 'LLL:EXT:bn_news/Resources/Private/Language/locallang_db.xml:tx_bnnews_domain_model_categories',
Model2:
$TCA['tx_aaext_domain_model_two'] = array(
'ctrl' => array(
'title' => 'Static Title',
and/or your extension-name has an underscore like aa_extension, then this error can happen.
Make sure that both title-definitions are dynamic and begin with "LLL:EXT:" and point to an existing translation. Everything should be fine now.
Long answer will be to long :)

sugarcrm globalsearch custom field

I want to implement the Global search for the Leads for the Primary address field ,i
followed the folllowing steps following this link.
once that has been done i have done quick repair and rebuild but im not able to get the
result .Any more thing to be done?
created a new file named customGlobalSearchFields.php in /custom/Extension/modules/Leads/ext/Vardefs/
and added the code below:
$dictionary['Leads']['fields']['primary_address_street']['unified_search'] = true;
Also added custom\modules\Leads\metadata\SearchFields.php
'primary_address_street' =>
array (
'query_type' => 'default',
),
You have enabled the Leads module for Global Search, right?
Please try this code..
custom\modules\Leads\metadata\SearchFields.php
'primary_address_street' =>
array (
'query_type' => 'default',
'force_unifiedsearch'=>true
),
Banti Gehlot