View Single Post
  #8  
Old 10-02-2019, 10:56 PM
 
Ed B. Ed B. is offline
 

X-Adept
  
Join Date: Apr 2016
Posts: 446
 

Default Re: "Fake" orders (or how do a cart become an order ?)

Quote:
Originally Posted by cflsystems
That's tricky and related to Doctrine. While I am not 100% (almost 100% sure though) sure this is how XC determines which records are orders and which are not - is_order = 1 for placed orders


The Repo Order class when creating the query builder uses "placedOnly" parameter. Search the class fot it and you will see how it adds condition to select only records that are an instance of Order.
Well,
Code:
/** * Create a new QueryBuilder instance that is prepopulated for this entity name * * @param string $alias Table alias OPTIONAL * @param string $indexBy The index for the from. OPTIONAL * @param boolean $placedOnly Use only orders or orders + carts OPTIONAL * * @return \XLite\Model\QueryBuilder\AQueryBuilder */ public function createQueryBuilder($alias = null, $indexBy = null, $placedOnly = true) { $result = parent::createQueryBuilder($alias, $indexBy); if ($placedOnly) { $result->andWhere($result->getMainAlias() . ' NOT INSTANCE OF XLite\Mod el\Cart'); } return $result; }

I didn't find the string "INSTANCE OF"... in any other class.



Are you implying that somehow because of
Code:
* @DiscriminatorColumn (name="is_order", type="integer", length=1) * @DiscriminatorMap ({1 = "XLite\Model\Order", 0 = "XLite\Model\Cart"})
my "fake orders" become instance of XLite\Model\Cart so that get ignored
in the search? Thus if I wanted search including fake orders, I would somehow
need to use

Code:
createQueryBuilder(o,'','false);

or something like that?


Quote:


The Model Order class has these Doctrine annotations
@DiscriminatorColumn
@DiscriminatorMap


These 2 tell DQL what determines the "instance of" condition



https://www.doctrine-project.org/projects/doctrine-orm/en/2.6/reference/annotations-reference.html#discriminatorcolumn
__________________
X-cart 5.2.12, php 5.6
Ed from Grenoble, France
Reply With Quote