Sep
07
Yeah.. OpenSource!
Ich habe durch Zufall noch eine alte Amazon Komponente gefunden die ich bisher nicht veröffentlich habe. Da ich mich ja auf GitHub niederlasse, habe ich die mal kurz überarbeitet und meinem cake-bits Repository hinzugefügt.
Link:
http://github.com/m3nt0r/cake-bits/tree/master/components/amazon.php
Gucken, und ...
PHP:
-
// some controller ...
-
-
function beforeFilter() {
-
$this->Amazon->setAccessKey( Configure::read('App.APIs.AmazonKey') );
-
$this->Amazon->setAssociateTag( Configure::read('App.APIs.AmazonTag') );
-
}
-
function index() {
-
$items = $this->Amazon->itemSearch('DVD', 'Title', 'Small,Offers');
-
if (!$items) {
-
pr ($this->Amazon->getLastErrors()); // pop some errors
-
} else {
-
$this->set('items', $items);
-
}
-
}
-
function view($asin) {
-
$item = $this->Amazon->itemLookup( $asin );
-
if (!$item) {
-
pr ($this->Amazon->getLastErrors()); // pop some errors
-
} else {
-
$this->set('item', $item);
-
}
-
}
Das wäre das eine... Das andere ist der remote shopping cart.
... kaufen!
PHP:
-
// some other controller ...
-
function add() {
-
if ($this->data) {
-
'quantity' => $this->data['Cart']['quantity'],
-
'offerId' => $this->data['Cart']['offerId']
-
) // ... could be a larger collection. no prob.
-
));
-
$this->redirect(aa('action', 'view'));
-
}
-
}
-
function edit() {
-
if ($this->data) {
-
$item_id = $this->data['Cart']['cartItemId'];
-
$quantity = $this->data['Cart']['quantity'];
-
$this->Amazon->cartUpdate($item_id, $quantity);
-
$this->redirect(aa('action', 'view'));
-
}
-
}
-
function view() {
-
$this->set('cart', $this->Amazon->cartGet());
-
$this->set('cartHasItems', $this->Amazon->cartHasItems());
-
$this->set('cartIsActive', $this->Amazon->cartIsActive());
-
}
Viel Spass damit!

