[TYPO3-mvc] Repository->add()
Daniel Dimitrov
danielsd_bg at yahoo.fr
Tue Jun 22 09:38:32 CEST 2010
I have decided to use PageTypes instead of exit(). Exit is fine, but I have
to start everything on my own, otherwise I cannot save, use fluid templates
etc.
I've followed the instructions in [TYPO3-mvc] [INFO] How-to do AJAX with
Extbase. Here is my setup config:
ajax = PAGE
ajax {
#typeNum = 1249058000
config {
disableAllHeaderCode = 1
additionalHeaders = Content-type:text/html
xhtml_cleaning = 0
admPanel = 0
}
}
bwshop_pi2 < ajax
bwshop_pi2 {
typeNum = 1249058991
10 < tt_content.list.20.bwshop_pi2
}
And it works fine, but when I try to use the Repository->add() method I get
an error:
Tx_Extbase_Persistence_Storage_Exception_SqlError
You have an error in your SQL syntax; check the manual that corresponds to
your MySQL server version for the right syntax to use near 'WHERE uid='52''
at line 1: UPDATE tx_bwshop_domain_model_cart SET WHERE uid='52'
Obviously something is wrong with my model cart, but I have no clue what it
can be? A new entry is saved in the database, but it has only uid and no
other columns have data in them.
Any ideas?
Daniel
"Daniel Dimitrov" <danielsd_bg at yahoo.fr> wrote in message
news:mailman.1.1276759589.9156.typo3-project-typo3v4mvc at lists.typo3.org...
> Hey Guys,
> I'm using exit(), because I use ajax and if I don't exit, then I get the
> whole page returned.
> Is there any way to use ajax + extabse?
> Kind regards,
> Daniel
>
> "Daniel Dimitrov" <danielsd_bg at yahoo.fr> wrote in message
> news:mailman.1.1276683923.12642.typo3-project-typo3v4mvc at lists.typo3.org...
>> Hey Guys,
>> I'm back from holiday and I have to start to annoy you again :D
>>
>> As you can see from the title I'm trying to use the Repository add
>> method, but for some unknown to me reason it doesn't work.
>>
>> Here is what I do:
>> I have a form like this:
>> <form id="myForm"
>> action="index.php?id=47448&tx_bwshop_pi2[action]=addToCart&tx_bwshop_pi2[controller]=Cart"
>> method="post">
>> <div id="form_box">
>> <input type="hidden" name="product_id" value="{product.uid}" />
>> <input type="submit" name="button" id="submit" />
>> </div>
>> </form>
>> <div id="addToCart" class="pointer">Add to cart</div>
>>
>> When I click on add to cart I make an ajax request to the Cart
>> controller:
>> $('submit').addEvent( 'click', function(evt){
>> // Stops the submission of the form.
>> new Event(evt).stop();
>>
>> // Sends the form to the action path,
>> // which is 'script.php'
>> $('myForm').send();
>> } );
>> (mootools 1.11)
>>
>> My addToCartAction looks like this:
>>
>> public function addToCartAction() {
>> $sessionId = $this->cartModel->getSessionId();
>>
>> $cart = t3lib_div::makeInstance('Tx_BwShop_Domain_Model_Cart');
>> $cart->setSessionId($sessionId);
>> $cart->setProduct($_POST['product_id']);
>> $cart->setQuantity(1);
>> $this->cartRepository->add($cart);
>> exit();
>> }
>> I don't get any error messages on this, but the cart object is also not
>> inserted in the database? Any ideas what could be wrong?
>>
>> Here is my CartModel:
>> class Tx_BwShop_Domain_Model_Cart extends
>> Tx_Extbase_DomainObject_AbstractEntity {
>> /**
>> *
>> * @var string
>> */
>> protected $sessionId;
>>
>> protected $quantity;
>>
>> /**
>> * @var Tx_BwShop_Domain_Model_Product
>> */
>> protected $product;
>>
>> public function getSessionId() {
>> $this->sessionId = $GLOBALS["TSFE"]->fe_user->id;
>> return $this->sessionId;
>> }
>>
>> public function getQuantity() {
>> return $this->quantity;
>> }
>>
>> /**
>> * Getter for supplier
>> *
>> * @return Tx_BwShop_Domain_Model_Product
>> */
>> public function getProduct() {
>> return $this->product;
>> }
>>
>> public function setSessionId($sessionId) {
>> $this->sessionId = $sessionId;
>> }
>>
>> public function setProduct($product) {
>> $this->product = $product;
>> }
>>
>> public function setQuantity($quantity) {
>> $this->quantity = $quantity;
>> }
>> }
>>
>> Thank you in advance!
>> Daniel
>
More information about the TYPO3-project-typo3v4mvc
mailing list