shop_baum
Total Posts: 13
Joined: 2008-12-15
Hallo,
ich habe eine eigene API geschrieben und möchte diese per SOAP ansprechen. Leider erhalte ich nach dem
SOAP-Call den Fehler “Class Mage not found”. Weiß hier jemand Rat?
Viele Grüsse
Sonja
Posted: January 9 2009
| top
timste
Total Posts: 643
Joined: 2007-12-26
Leipzig
? hast du mal nen schnipsel
Grüße
Posted: January 9 2009
| top
| # 1
shop_baum
Total Posts: 13
Joined: 2008-12-15
klar, hier ist die
app/code/local/imx/cartt/etc/api.xml
<?xml version = "1.0" ?> < config > < api > < resources > < cartt translate = "title" module = "imx_cartt" > < title > IMX Cart Api </ title > < model > imx_cartt / api </ model > < methods > < addProduct translate = "title" module = "imx_cartt" > < title > addProduct </ title > </ addProduct > </ methods > </ cartt > </ resources > </ api > </ config >
Hier ist die
app/code/local/imx/cartt/etc/config.xml
<?xml version = "1.0" encoding = "UTF-8" ?> < config > < modules > < imx_cartt > < version > 0.1.0 </ version > </ imx_cartt > </ modules > <global> < models > < cartt > <class> imx_cartt_Model </class> </ cartt > </ models > </global> </ config >
app/code/local/imx/cartt/Model/Api.php
<?php class imx_cartt_Model_Api extends Mage_Api_Model_Resource_Abstract { public function addProduct ( $arg ) { echo "Hello World, here is my argument: " . $arg ; } } ?>
und hier ist noch
app/etc/modules/imx_cartt.xml
<?xml version = "1.0" ?> < config > < modules > < imx_cartt > < active > true </ active > < codePool > local </ codePool > </ imx_cartt > </ modules > </ config >
Muss ich für den Soap-Zugriff noch speziell etwas hinzufügen?
Viele Grüsse
Sonja
Posted: January 9 2009
| top
| # 2
timste
Total Posts: 643
Joined: 2007-12-26
Leipzig
ahem,
was möchtest du eigentlich genau machen?
gruss
Posted: January 9 2009
| top
| # 3
shop_baum
Total Posts: 13
Joined: 2008-12-15
Per Soap hole ich mir die Produkte in einen Internetauftritt. In diesem Portal kann der User dann die Produkte in den Warenkorb legen und dann auch bestellen. Der User soll aber nicht in den Shop wechseln müssen, sondern soll in dem Portal bleiben.
Daher möchte ich die Funktionen per SOAP ansprechen.
Das war jetzt die Kurzform. Warum dies so sein muss, hängt mit den Anforderungen des Projekts zusammen, das würde aber hier den Rahmen sprengen.
Meine Code-Beispiele sind nun erstmal dafür vorhanden, dass ich eine Funktion per SOAP aufrufen kann. Die Funktionen für den eigentlichen Verwendungszweck fehlen noch.
Viele Grüsse
Sonja
Posted: January 9 2009
| top
| # 4
timste
Total Posts: 643
Joined: 2007-12-26
Leipzig
nur noch mal so für mich
du rufst das was du oben gepostet hast auf dem portal-server auf oder auf dem server wo magento liegt?
Grüße
Posted: January 9 2009
| top
| # 5
shop_baum
Total Posts: 13
Joined: 2008-12-15
das rufe ich auf dem Portal-Server per Soap auf.
Hier ist der Code. In dem $conf-Array sind meine Einstellungen (also URL, User und Passwort).
$client = new SoapClient ( $conf[ "serviceURL" ] ,array( "trace" => 1 )); $sess_id = $client -> login ( $conf[ "serviceUser" ] , $conf[ "servicePassword" ] ); $result = $client -> call ( $sess_id , "cartt.addProduct" , $parameter );
viele Grüsse
Sonja
Posted: January 9 2009
| top
| # 6
MichaelG.
Total Posts: 18
Joined: 2008-09-25
Germany
Hey Sonja,
hier ist mein Code für den Warenkorb.... er baut allerdings auf den internen Klassen von Magento auf....
$artikel_sku //übergebene SKU $menge //übergebene Menge $model = Mage :: getModel ( 'catalog/product' ); // Hier suchen Wir das Produkt mittels SKU, $prodId = $model -> getIdBySku ( $artikel_sku ); $product = Mage :: getModel ( 'catalog/product' )-> load ( $prodId ); //Produkt in den Warenkorb legen $cart = Mage :: getModel ( 'checkout/cart' ); $cart -> addProduct ( $product , array( 'qty' => $menge )); $cart -> save ();
Ich hoffe ich konnte dir damit helfen.
Gruß
Michael
Signature
"There is a theory which states that if ever anyone discovers exactly what the Universe is for and why it is here, it will instantly disappear and be replaced by something even more bizarre and inexplicable.
There is another theory which states that this has already happened”
Posted: January 9 2009
| top
| # 7
MichaelG.
Total Posts: 18
Joined: 2008-09-25
Germany
Ah vielleicht ist das noch wichtig.
Meine Klasse ist eine Erweiterung der “Mage_Core_Controller_Front_Action” Klasse.
Michael
Signature
"There is a theory which states that if ever anyone discovers exactly what the Universe is for and why it is here, it will instantly disappear and be replaced by something even more bizarre and inexplicable.
There is another theory which states that this has already happened”
Posted: January 9 2009
| top
| # 8