Example #1
0
 public function testToArrayFromArray()
 {
     $impression = new Impression();
     $impression->setId('id');
     $impression->setSku('zzzz');
     $impression->setTitle('Product X');
     $impression->setCategory('Category A');
     $impression->setAction('detail');
     $impression->setBrand('Brand A');
     $impression->setList('Search Results A');
     $impression->setPrice(50.0);
     $impression->setPosition(1);
     $impression->setVariant('Black');
     $toArray = $impression->toArray();
     $impression2 = new Impression();
     $impression2->fromArray($toArray);
     $this->assertEquals($impression, $impression2);
 }
Example #2
0
 /**
  * @param string $action
  *
  * @return array[] AntiMattr\GoogleBundle\Analytics\Impression $impressions
  */
 private function getImpressionsFromSession($action = '')
 {
     $impressionArray = $this->get(self::EC_IMPRESSIONS_KEY . '/' . $action);
     $hydratedImpressions = array();
     foreach ($impressionArray as $value) {
         if (is_object($value)) {
             $hydratedProducts[] = $value;
             continue;
         }
         $impression = new Impression();
         $impression->fromArray($value);
         $hydratedImpressions[] = $impression;
     }
     return $hydratedImpressions;
 }