예제 #1
0
파일: Inventory.php 프로젝트: Eximagen/3m
function save_product_combination($ProductId,$itemNumber,$list, $decoration){
        global $webService,$webservice_exi,$result_xml, $count;
        StockAvailableCore::deleteStockInventoryBYProductID($ProductId);
        
        $opt = array('resource' => 'combinations');
        
        $parameter = array("ItemNumber"=>$itemNumber,
			"key"=>EXIMAGEN_KEY);
        $i=0;
        $inventory_details = $webservice_exi->GetInventory($parameter);
		$color_array = array();
		if(isset($inventory_details->GetInventoryResult->InventoryData->SKU))
            $inventory_details = $inventory_details->GetInventoryResult;
        else
            $inventory_details = $inventory_details->GetInventoryResult->InventoryData;
        foreach ($inventory_details as $inventory){
                $color_id = AttributeCore::getColorAttributeIdByValue($inventory->HexValue);
                         getIdStockAvailableAndSet($ProductId, $inventory->Available,
                   $inventory->OnTransit,$inventory->Date,$color_id);
                
            $intransit_date = $inventory->Date;
            if($intransit_date=='N/A')
                $intransit_date = date("Y-m-d");
                StockAvailableCore::setStockInventory($ProductId, 1, 0,$inventory->Available,$color_id,
                   $inventory->OnTransit,$intransit_date);
        }
}
예제 #2
0
 public function getAttributes()
 {
     return AttributeCore::getAttributes($_GET['id_lang']);
 }
예제 #3
0
function save_product_combination($ProductId,$itemNumber,$list, $decoration,$color_name){
	global $webService,$webservice_exi,$result_xml, $count;
        deleteImagesToProducts($ProductId);
        $comb_ids = CombinationCore::getIdsByProductId($ProductId);
        StockAvailableCore::deleteStockInventoryBYProductID($ProductId);
        
        $opt = array('resource' => 'combinations');
        foreach ($comb_ids as $comb){
             $opt['id'] = (int)$comb['id_product_attribute'];
             $xml = $webService->delete($opt);             
        }
        
        $product_xml = $result_xml->ProductListResult->ProductListResult;
        $parameter = array("ItemNumber"=>$itemNumber,
			"key"=>"8770471727");
        $i=0;
        $inventory_details = $webservice_exi->GetInventory($parameter);
		$color_array = array();
		if(isset($inventory_details->GetInventoryResult->InventoryData->SKU))
            $inventory_details = $inventory_details->GetInventoryResult;
        else
            $inventory_details = $inventory_details->GetInventoryResult->InventoryData;
        foreach ($inventory_details as $inventory){
            attachImages($inventory->SKU, $ProductId);
                $xml = $webService -> get(array('url' => PS_SHOP_PATH . '/api/combinations?schema=synopsis'));
                $resources = $xml -> children() -> children();
                $resources->id_product  = $ProductId;
                $resources->quantity = $inventory->Available;
                if($i==0){
                    $resources->default_on = true;
                    $i++;
                }
                $resources->minimal_quantity = 1;
                $resources->reference = $inventory->SKU;
                $color_id = AttributeCore::getColorAttributeIdByValue($inventory->HexValue);
                if(!$color_id){
                    $xml1 = $webService -> get(array('url' => PS_SHOP_PATH . '/api/product_option_values?schema=synopsis'));
                    $resources1 = $xml1 -> children() -> children();
                    $resources1->id_attribute_group  = 3;
                    $resources1->color  = "#".$inventory->HexValue;
                    $resources1->name->language[0]  = $product_xml[$count-1]->Color;
                    $resources1->name->language[1]  = $product_xml[$count-1]->Color;
                     try {
                        $opt1 = array('resource' => 'product_option_values');
                        $opt1['postXml'] = $xml1->asXML();
                        $xml1 = $webService->add($opt1);
                        $result1 = $xml1->children()->children();
                        $color_id = $result1->{'id'};
                    }catch (PrestaShopWebserviceException $ex) {
                            echo "<b>Error al setear la cantidad  ->Error : </b>".$ex->getMessage().'<br>';
                    }
                }
                if(in_array($color_id,$color_array))
					continue;
				else
					array_push($color_array,$color_id);
				
                var_dump($color_id);
                $resources->associations->product_option_values->product_option_values->id=$color_id;
               try {
                        $opt = array('resource' => 'combinations');
                        $opt['postXml'] = $xml->asXML();
                        $xml = $webService->add($opt);
                         getIdStockAvailableAndSet($ProductId, $inventory->Available,
                   $inventory->OnTransit,$inventory->Date,$color_id);
                         $count++;
                }catch (PrestaShopWebserviceException $ex) {
                        echo "<b>Error al setear la cantidad  ->Error : </b>".$ex->getMessage().'<br>';
                }
            $intransit_date = $inventory->Date;
            if($intransit_date=='N/A')
                $intransit_date = date("Y-m-d");
                StockAvailableCore::setStockInventory($ProductId, 1, 0,$inventory->Available,$color_id,
                   $inventory->OnTransit,$intransit_date);
        }
}
예제 #4
0
 /**
  * Get all attributes for a given language
  *
  * @param int $id_lang Language id
  * @param bool $not_null Get only not null fields if true
  *
  * @return array Attributes
  */
 public static function getAttributes($id_lang, $not_null = false)
 {
     return \AttributeCore::getAttributes($id_lang, $not_null);
 }