1

In my own extension i need to include some of the deleted elements in the list view.

I have included this in the domian model

/**
 * @var bool
 */
protected $deleted;
/**
 * @return int
 */
public function getDeleted()
{
    return $this->deleted;
}
/**
 * @param bool $deleted
 */
public function setDeleted($deleted)
{
    $this->deleted = $deleted;
}

And in the repository I have this

$query = $this->createQuery();
    $query->getQuerySettings()->setIncludeDeleted(true);
    if($sort==""){$sort = "make";}

    $query->statement('SELECT tx_origcarinfo_domain_model_car.* 
                        FROM tx_origcarinfo_domain_model_car 
                        WHERE categories LIKE "%'.$cat.'%" 
                        AND ((hidden = 0 AND deleted = 0) OR (deleted = 1                           AND tstamp > '.(date("U")-1209600).'))  
                        GROUP by car_id
                        ORDER by '.$sort
                        );
    }
    return $query->execute();

But if I debug my output deleted is NULL in every element.

Jeppe Donslund
  • 469
  • 9
  • 25
  • Look´s good. Have you checked if `date("U")-1209600` gives the right value? I have this not tested but i think `NOW()-1209600` should work. – Mirko Brunner Jan 23 '17 at 21:57
  • setIncludeDeleted is the correct approach. I'd go ahead and debug the query: http://stackoverflow.com/questions/5075296/how-to-debug-a-query-in-extbase – j4k3 Jan 25 '17 at 08:14
  • It does return elements where deleted = 1, but in the output, Deleted is show as NULL for every element despite of the value in the database. I was expecting 1 or 0. – Jeppe Donslund Jan 25 '17 at 08:42
  • In the model, the return value was set to Bool, when I set it to Int everything worked fine. – Jeppe Donslund Jan 25 '17 at 13:03

1 Answers1

0

You have done right thing Jeppe but one more thing to do is that you have to create one file in extension directory named ext_typoscript_setup.txt

config.tx_extbase{
    persistence{
        classes{
            <Namespace>\Domain\Model\<Modelfile> {
                mapping {
                    tableName = tx_<TableName>
                    columns {
                        deleted.mapOnProperty = deleted
                    }
                }
            }
        }
    }
}

After adding this file uninstall and install your extension.

Ashish Patel
  • 1,011
  • 13
  • 27