0
votes

First of all, i create a Extension with the "Extension Builder". I would like to extend the "tt_address" Extension.

What steps i do?

  1. I create a Entity Adress and map this to existing table tt_address. In my Entity Address i create setter and getter for retrieving Addressinformations like 'city, zip and street'.

  2. After this step i create a Repository AddressRepository which extends \TYPO3\CMS\Extbase\Persistence\Repository.

  3. The extensionbuilder create a typoscript File ext_typoscript_setup.txt with this content:

    config.tx_extbase{ persistence{ classes{

            Mab\Oaaddress\Domain\Model\Address {
                mapping {
                    tableName = tt_address
                    recordType = Tx_Oaaddress_Address
                }
            }
    
        }
    }}
    
  4. I set the storagePid in my constants.txt

In the last step i would like to retrieve all Addresses from Database and show this in a list view.

class AddressController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController {

    /**
     * Events repository
     *
     * @var \Mab\Oaaddress\Domain\Repository\AddressRepository
     * @inject
     */
    protected $addressRepository;

    /**
     * action list
     *
     * @return void
     */
    public function listAction() {
        // Exists adress repository?
        //var_dump($this->addressRepository);
        $addresses = $this->addressRepository->findAll();
        //var_dump(count($addresses));
        $this->view->assign('addresses', $addresses);
    }

The table tt_address contains more than ten results. But the controller show $addresses count always 0. I clear every Cache (empty Typo3Temp folder, empty Cache through Install Tool, emptyh Backend Cache) but nothing have a effect. Why my Controller return nothing? Can someone give me a tip?

Update

After i analyse the query log, i find that this query is executed:

SELECT  tt_address.* FROM tt_address  WHERE 1=1 AND (tt_address.tx_extbase_type='Tx_Oaaddress_Address') AND tt_address.pid IN (148) AND tt_address.deleted=0 AND tt_address.hidden=0

How can i remove this part

tt_address.tx_extbase_type='Tx_Oaaddress_Address' from the where part of the query?

1
You can take a look at mysql's general.log. In your Terminal, find out where the logfile is (e.g. /var/log/mysql5/general.log) and then do tail -n 3000 /var/log/mysql5/general.log | grep tt_address This could help you to find the sql query that was called and you may see what is going wrong. - Jay Dinse
@jay-dinse Thank you a lot for your hint, i find the executed query and updated my question. - smartcoderx

1 Answers

0
votes

You can add:

config.tx_extbase {
    persistence {
        classes {
            FriendsOfTYPO3\TtAddress\Domain\Model\Address {
                mapping {
                    tableName = tt_address
                    recordType = Tx_TtAddress_Listview
                }
            }
        }
    }
}

And add "Tx_TtAddress_Listview" to your tx_extbase_type like: // Configuration/TCA/Overrides/tt_address.php

$tempColumnstx_yourext_tt_address[$GLOBALS['TCA']['tt_address']['ctrl']['type']] = [
    'exclude' => true,
    'label' => 'yourLabe for Type',
    'config' => [
        'type' => 'select',
        'renderType' => 'selectSingle',
        'items' => [
            ['Person','Tx_TtAddress_Listview'],
            ['MyLabel','Tx_YourExt_type']
        ],
        'default' => 'Tx_TtAddress_Listview',
        'size' => 1,
        'maxitems' => 1,
    ]
];

This adds a or to the SQL statement like:

... WHERE ((`tt_address`.`t
   x_extbase_type` = Tx_YourExt_type) OR (`tt_address`.`tx_extbase_type` = Tx_TtAddress_Listview) ...