Jump to content

TheLousyCoder

Members
  • Posts

    31
  • Joined

  • Last visited

1 Follower

Profile Information

  • Location
    Mumbai
  • Activity
    Developer

Recent Profile Visitors

578 profile views

TheLousyCoder's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. Hi Gautam, Did you find any solution adding image to the product? Will you please share any code to do so?? Regards
  2. I am developing API in PHP only. I will be glad to help if you need something.
  3. Hi Nikhil, I somehow made a function that will authenticate a user, I asked my Java developer to store and maintain the userid that I pass after successful authentication. Below function that I write might help you. public function authenticate($email, $passwd) { $errors = array(); $ct = array(); Hook::exec('actionBeforeAuthentication'); //echo 'hook exe'; $passwd = trim($passwd); $email = trim($email); if (empty($email)) { $errors[] = 'An email address required.'; } elseif (!Validate::isEmail($email)) { $errors[] = 'Invalid email address.'; } elseif (empty($passwd)) { $errors[] = 'Password is required.'; } elseif (!Validate::isPasswd($passwd)) { $errors[] = 'Invalid password.'; } else { $customer = new Customer(); $context = Context::getContext(); $authentication = $customer->getByEmail(trim($email), trim($passwd)); if (!$authentication || !$customer->id) { $errors = Tools::displayError('Email/Password is wrong.'); } else { $context->cookie->id_compare = isset($context->cookie->id_compare) ? $context->cookie->id_compare : CompareProduct::getIdCompareByIdCustomer($customer->id); $context->cookie->id_customer = (int) ($customer->id); $context->cookie->customer_lastname = $customer->lastname; $context->cookie->customer_firstname = $customer->firstname; $context->cookie->logged = 1; $customer->logged = 1; $context->cookie->is_guest = $customer->isGuest(); $context->cookie->passwd = $customer->passwd; $context->cookie->email = $customer->email; // Add customer to the context $context->customer = $customer; if (Configuration::get('PS_CART_FOLLOWING') && (empty($context->cookie->id_cart) || Cart::getNbProducts($context->cookie->id_cart) == 0) && $id_cart = (int) Cart::lastNoneOrderedCart($context->customer->id)) { $context->cart = new Cart($id_cart); } else { $context->cart->id_carrier = 0; $context->cart->setDeliveryOption(null); $context->cart->id_address_delivery = Address::getFirstCustomerAddressId((int) ($customer->id)); $context->cart->id_address_invoice = Address::getFirstCustomerAddressId((int) ($customer->id)); } $context->cart->id_customer = (int) $customer->id; $context->cart->secure_key = $customer->secure_key; $context->cart->save(); $context->cookie->id_cart = (int) $context->cart->id; $context->cookie->write(); $context->cart->autosetProductAddress(); Hook::exec('actionAuthentication'); $ct['cart'] = (array) get_object_vars($context->cart); $ct['customer'] = (array) get_object_vars($context->customer); $ct['cookie'] = (array) get_object_vars($context->cookie); // print_r($ct); $token = Tools::getToken(false); } } if (count($errors) > 0) { $fjson = json_encode($errors, true); } else { $fjson = json_encode($ct, true); } $res = '{' . '"status":200,' . '"datajson":' . $fjson . '}'; return $res; }
  4. No one have any idea? Come on Presta Superstars... Please guide me to cache all html generated by smarty and store on amazon cdn ..
  5. Hi All, My shop is loading too slow and I wanted to implement caching full page using apc (or suggest any other method). I tried my luck with some modification in code but couldn't do much. I have my back-end hosted on another domain and not a problem if some changes to affect backend. I want to develop the code such that it will first check if html is present in apc store , fetch from apc or construct html store in apc and then echo to browser. I want it to work mainly for category and product controllers. Please suggest any work around for the same. Any help will greatly be appreciated. prestashop version is 1.5.6 Thanks...
  6. Thanks fred-vinapresta , this helped me a lot... I can successfully apply voucher to the cart. Below is the code which worked for me if (($cartRule = new CartRule(CartRule::getIdByCode($coupon))) && Validate::isLoadedObject($cartRule)) { $cart = new Cart($cartid); $cartresult = $cart->addCartRule($cartRule->id); $cartProducts = $cart->getCartRules(); $cou = array('success' => 'true', 'discount' => $cartProducts[0]['value_real']); $coujson = json_encode($cou, true); }
  7. Hi fred-vinapresta, Thanks a lot for reply. But I don't want to create a coupon, I want to redeem a coupon. I want to take a coupon code from my app user and apply it on the cart so that discounts are availed. Is there any function in prestashop already that will help me do this or any trick?
  8. Hi All, I am developing APIs for mobile app. I am stuck at the point where I want to apply coupon code on the cart. I want to know how If there is any function calling which will return me the discounts applicable on coupon. Any help will greatly appreciated. Regards
  9. I am trying to reduce the load on master database by separating queries. I have my huge shop having almost 1200 categories. I have currently two database servers, a Master and a Slave. I need to allocate read queries (select, explain, describe ) to slave db and write queries (update, delete, insert etc ) to Master database. I am new to prestashop and your help doing this, any help will greatly appreciated. Edit: running version 1.5.6 Thanks in advance.
  10. Well, Problem resolved . It was just a spelling mistake of "context" line $contaxt = Context::getContext(); should be $context = Context::getContext();
  11. For more info, Here is the code I am trying to get working. public function checkuser($email, $passwd) { $error = array(); Hook::exec('actionBeforeAuthentication'); //echo 'hook exe'; $passwd = trim($passwd); $email = trim($email); if (empty($email)) { $errors[] = 'An email address required.'; } elseif (!Validate::isEmail($email)) { $errors[] = 'Invalid email address.'; } elseif (empty($passwd)) { $errors[] = 'Password is required.'; } elseif (!Validate::isPasswd($passwd)) { $errors[] = 'Invalid password.'; } else { $contaxt = Context::getContext(); $customer = new Customer(); $authentication = $customer->getByEmail(trim($email), trim($passwd)); if (!$authentication || !$customer->id) { $errors = Tools::displayError('Email/Password is wrong.'); } else { $context->cookie->id_compare = isset($context->cookie->id_compare) ? $context->cookie->id_compare : CompareProduct::getIdCompareByIdCustomer($customer->id); $context->cookie->id_customer = (int) ($customer->id); $context->cookie->customer_lastname = $customer->lastname; $context->cookie->customer_firstname = $customer->firstname; $context->cookie->logged = 1; $customer->logged = 1; $context->cookie->is_guest = $customer->isGuest(); $context->cookie->passwd = $customer->passwd; $context->cookie->email = $customer->email; // Add customer to the context $context->customer = $customer; if (Configuration::get('PS_CART_FOLLOWING') && (empty($context->cookie->id_cart) || Cart::getNbProducts($context->cookie->id_cart) == 0) && $id_cart = (int) Cart::lastNoneOrderedCart($context->customer->id)) { $context->cart = new Cart($id_cart); } else { $context->cart->id_carrier = 0; $context->cart->setDeliveryOption(null); $context->cart->id_address_delivery = Address::getFirstCustomerAddressId((int) ($customer->id)); $context->cart->id_address_invoice = Address::getFirstCustomerAddressId((int) ($customer->id)); } $context->cart->id_customer = (int) $customer->id; $context->cart->secure_key = $customer->secure_key; $context->cart->save(); $context->cookie->id_cart = (int) $context->cart->id; $context->cookie->write(); $context->cart->autosetProductAddress(); print_r($context); die; Hook::exec('actionAuthentication'); //echo 'haha'; } } if (count($errors) > 0) $fjson = json_encode($errors); else $fjson = json_encode($context); $res = '{' . '"status":200,' . '"datajson":' . $fjson . '}'; return $res; } Ideally, my json should reply with authentication token and context related info to app whenever asked with username and password.
  12. I think you are getting me wrong, I have prestashop 1.5.6, on that I am writing API script for mobile app. I have included init.php in my code and trying to authenticate the user. I tried code written in Authcontroller but not able to get the user context.
  13. I am basically at server side, writing code in PHP for authentication. If you can help me with that
  14. Thanks Nemo for reply. I am already working the same way as you suggested. Currently developing Android app using Java. But, I am not sure how would I go for authentication , I have created restful APIs for products and categories but this is freaking me out. Can you please help me in this regard, Any logic or code will be pretty helpful.
  15. Hi, I am writing APIs for mobile app. I am stuck at the point how to authenticate users for mobile app with prestashop web services or API. Please help me, it's urgent
×
×
  • Create New...