$value ) { $entry[$key] = $this->spaceMeansEmpty($value); } $products = array(); $magentoProduct->setData($entry); $magentoProduct->setSku($entry['Ean']); $magentoProduct->setName($entry['Kparam2']); $magentoProduct->setSize($entry['Vparam4']); $magentoProduct->setQty($entry['Qty']); $magentoProduct->setPrice($entry['SalesPriceEach']); $magentoProduct->setCost($entry['CostpriceEach']); $magentoProduct->setBrand($entry['SupplierName']); $magentoProduct->setEdbNumber($entry['EdbNumber']); $magentoProduct->setTypeId( 'simple' ); if ( $entry['Vparam1'] ) { $magentoProduct->setColor( $entry['Vparam1'] ); } $products []= $magentoProduct; $parentSku = $entry['KatalogNumber']; if ( $entry['Vparam1'] ) $parentSku .= " - " . $entry['Vparam1']; $magentoProduct->setConfigurableParentSku($parentSku); if ( !isset($this->_confSkus[$parentSku]) ) { $this->_confSkus[$parentSku] = 1; $confProduct = clone $magentoProduct; $confProduct->setSku($parentSku); $confProduct->unsData('size'); $confProduct->unsData('qty'); $confProduct->unsData('ean'); $confProduct->setTypeId('configurable'); $products []= $confProduct; } return $products; } public function getProducts() { $test = new SoapClient("http://api.dddadmin.com/StockService.svc?wsdl"); $data = $test->GetWebshopArticlesPaged(array("groupId" => "237", "shopid"=>1, "sinceEdbNumber" => 1, "psk" => self::DDD_CLIENT_KEY)); $data = json_decode($data->GetWebshopArticlesPagedResult); $eans = array(); $entries_by_eans = array(); foreach ( $data as $entry ) { $eans []= $entry->Ean; $entries_by_eans[$entry->Ean] = $entry; } //var_dump ( $eans ); $stock = $test->StockCountByParameter( array("eans" => $eans, "client" => self::DDD_CLIENT_NUMBER, "psk" => self::DDD_CLIENT_KEY) ); $stock = $stock->StockCountByParameterResult->KeyValueOflongint; foreach ( $stock as $stock_entry ) { $ean = $stock_entry->Key; $entries_by_eans[$ean]->Qty = $stock_entry->Value; } // ddd API requires it sleep(30); $data = $test->GetWebshopArticlesPaged(array("groupId" => "237", "shopid"=>2, "sinceEdbNumber" => 1, "psk" => self::DDD_CLIENT_KEY)); //$data = $test->GetWebshopArticlesPaged(array("groupId" => "237", "shopid"=>"237002", "sinceEdbNumber" => 0, "psk"=>"59cmsI923mSK12sXm39mSa9157caq15vxalSfks2")); $data = json_decode($data->GetWebshopArticlesPagedResult); $eans = array(); foreach ( $data as $entry ) { $eans []= $entry->Ean; $entries_by_eans[$entry->Ean] = $entry; } if ( count($eans) ) { $stock = $test->StockCountByParameter( array("eans" => $eans, "client" => self::DDD_CLIENT_NUMBER + 1, "psk" => self::DDD_CLIENT_KEY) ); $stock = $stock->StockCountByParameterResult->KeyValueOflongint; foreach ( $stock as $stock_entry ) { $ean = $stock_entry->Key; $entries_by_eans[$ean]->Qty = $stock_entry->Value; } } return $entries_by_eans; } }