/**
  * @see FrontController::initContent()
  */
 public function initContent()
 {
     parent::initContent();
     try {
         if (!Maestrano::param('connec.enabled')) {
             return false;
         }
         $client = new Maestrano_Connec_Client();
         $notification = json_decode(file_get_contents('php://input'), false);
         $entity_name = strtoupper(trim($notification->entity));
         $entity_id = $notification->id;
         switch ($entity_name) {
             case "PERSONS":
                 $customerMapper = new CustomerMapper();
                 $customerMapper->fetchConnecResource($entity_id);
                 break;
             case "ITEMS":
                 $productMapper = new ProductMapper();
                 $productMapper->fetchConnecResource($entity_id);
                 break;
             case "TAXCODES":
                 $taxMapper = new TaxMapper();
                 $taxMapper->fetchConnecResource($entity_id);
                 break;
         }
     } catch (Exception $e) {
         error_log("Caught exception in subscribe " . json_encode($e->getMessage()));
     }
 }
 protected function mapModelToConnecResource($product)
 {
     $product_hash = array();
     //$product_hash['serial_number'] = $product->column_fields['serial_no'];
     //$product_hash['part_number'] = $product->column_fields['productcode'];
     // Map attributes
     $product_hash['code'] = $product->reference;
     $product_hash['name'] = $product->name[1];
     $product_hash['description'] = $product->description[1];
     $product_hash['sale_price'] = array('net_amount' => $this->format_string_to_decimal($product->price));
     // Default product type to PURCHASED on creation
     if ($this->is_new($product)) {
         $product_hash['type'] = 'PURCHASED';
     }
     //Product Weight
     $product_hash['weight'] = $product->weight;
     // Product Status
     $product_hash['status'] = $product->active ? "ACTIVE" : "INACTIVE";
     // Inventory tracking
     $qtyinstock = $this->format_string_to_decimal($product->quantity);
     $product_hash['quantity_on_hand'] = $qtyinstock;
     // Tax for th Product
     ProductMapper::mapTaxToConnecResource($product, $product_hash);
     return $product_hash;
 }
 public function find($status = null)
 {
     $result = array();
     $sql = 'SELECT product_id, product_name, price FROM products;';
     foreach ($this->query($sql) as $row) {
         $product = new Product();
         ProductMapper::map($product, $row);
         $result[$product->getProductId()] = $product;
     }
     return $result;
 }
 public function hookActionObjectProductDeleteAfter($params)
 {
     $ProductMapper = new ProductMapper();
     $ProductMapper->processLocalUpdate($params['object'], false, true);
 }