Search the Community
Showing results for tags 'prestashop'.
-
Hi, I am not a coder, but I have this issue with my ecommerce platform which is based on Prestashop. So could You please explain to me what is the purpose of this php script below? Whap is gonna to happen if I delete it (this script is giving me an error)? <?php $host = "http://localhost:8080"; $company = "BlueSky"; $email = "lisa.penvenen@gmail.com"; $price = "1000"; $offerNumber = "958"; $description = "My invoice"; $street = "Baker street 221B"; $city = "London"; $ch = curl_init(); curl_setopt($ch, CURLOPT_USERPWD, "lisa.penvenen:mypass"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($ch, CURLOPT_HTTPAUTH, TRUE); $id = send($ch, $host, $company, $description, $price, $offerNumber, $street, $city); sendEmail($ch, $host, $company, $id, $email); curl_close($ch); function send($ch, $host, $company, $description, $price, $offerNumber, $street, $city) { curl_setopt($ch, CURLOPT_URL, $host . "/c/" . $company . "/invoice-issued.json"); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT"); $invoice = array( "winstrom" => array( "invoice-issued" => array( "documentType" => "code:INVOICE", "mine" => "code:WINSTROM", "description" => $popis, "total" => $price, "noItems" => "true", "offerNumber" => $offerNumber, "street" => $ulice, "city" => $mesto, ) ) ); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($invoice)); $output = curl_exec($ch); if (curl_getinfo($ch, CURLINFO_HTTP_CODE) != 200 && curl_getinfo($ch, CURLINFO_HTTP_CODE) != 201) { printf("Error occurred during the operation (HTTP %d): %sn", curl_getinfo($ch, CURLINFO_HTTP_CODE), $output); } else { $id = get_id($output); printf("Success (1) s ID: %s <br/>", $id); return $id; } } function get_id($output) { $id = 0; $jsonIterator = new RecursiveIteratorIterator( new RecursiveArrayIterator(json_decode($output, TRUE)), RecursiveIteratorIterator::SELF_FIRST); foreach ($jsonIterator as $key => $val) { if (!is_array($val)) { if ('id' == $key) { $id = $val; } } } return $id; } function sendEmail($ch, $host, $company, $id, $email) { curl_setopt($ch, CURLOPT_URL, $host . "/c/" . $company . "/invoice-issued/" . $id . "/sending-documents.xml"); curl_setopt($ch, CURLOPT_POSTFIELDS, "to=" . $email . "&subject=Invoice"); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT"); $output = curl_exec($ch); if (curl_getinfo($ch, CURLINFO_HTTP_CODE) != 200 && curl_getinfo($ch, CURLINFO_HTTP_CODE) != 201) { printf("rror occurred during the operation (HTTP %d): %sn", curl_getinfo($ch, CURLINFO_HTTP_CODE), $output); } else { printf("Success (2)"); } } ?>
-
I am a freelance programmer from India having more than 14 years experience in web development and 8 years experience in PHP/MySQL. I am very interested in long term business relationship with web designers or internet marketeers. Please check out my portfolio at http://www.harshadnair.com/portfolio/ My hourly rates are very competitive and among the lowest you can get! If interested, mail me at harshad.nair@gmail.com or add me to Skype: harshad.nair You will always find the projects delivered by me to be of the best quality and well within time. Some samples of my work: http://www.pcmedicstores.com/pcm http://www.crazy4sportz.com http://www.royalparkwine.com http://www.angloamericandarts.com http://www.harshadnair.com/web http://www.visaworks.com http://www.h1bplanet.com http://www.financialcompound.com http://www.vliegennaar.net http://www.simlockvrijetelefoon.nl http://www.traveltravel.nl http://www.alexpadillabailbonds.com http://www.allayechan.com http://www.hotelaanbiedingen.com http://www.healthwavehgh.com http://www.andersonschoech.com/ http://www.forinjuryadvice.com/ http://dblawpractice.com http://barbaragreer.com/ http://www.weinbergerlaw.net http://www.visa4you.info http://www.gotlegalproblems.com Thanks and regards, HN
-
- prestashop
- php
-
(and 3 more)
Tagged with:
-
I posted this on a forum and i got a response but it did not work for me ... What I'm trying to do is to get the category image to show instead of the product image. What I have done for the category product list which works is this. This only works if you are looking at all the products in a category but not if you search for a product? <a href="{$product.link|escape:'htmlall':'UTF-8'}" class="product_img_link" title="{$product.name|escape:'htmlall':'UTF-8'}"> <img src="{$link->getCatImageLink($category->link_rewrite, $category->id_image, 'large_default')}" style="width:140px!important;" alt="{$product.legend|escape:'htmlall':'UTF-8'}" /> </a> I was wondering how do I get this to work all of the site? How do I make it pull the category images? Like it is above but for the whole site? This was his response and i dont know what it means... You can do a multiple actions to create such an image, first of all you call for $category class in product page, so $category is not defined. best solution is to create a assigment for $category in productController in override directory. class ProductController extends ProductControllerCore { public function initContent() { parent::initContent(); $category = new Category($this->product->id_category_default); $this->context->smarty->assign('category', $category); } }
-
I need to output in product-list.tpl file the result of a query from within classes/Search.php in Prestashop. The query in classes/Search.php is: $sql = 'SELECT * FROM `'._DB_PREFIX_.'category_group` cg INNER JOIN `'._DB_PREFIX_.'category_product` cp ON cp.`id_category` = cg.`id_category` INNER JOIN `'._DB_PREFIX_.'category` c ON cp.`id_category` = c.`id_category` INNER JOIN `'._DB_PREFIX_.'product` p ON cp.`id_product` = p.`id_product` INNER JOIN `'._DB_PREFIX_.'product_part_number` ON p. `id_product` = `ID` '.Shop::addSqlAssociation('product', 'p', false).' WHERE c.`active` = 1 AND product_shop.`active` = 1 AND product_shop.`visibility` IN ("both", "search") AND product_shop.indexed = 1 AND cg.`id_group` '.(!$id_customer ? '= 1' : 'IN ( SELECT id_group FROM '._DB_PREFIX_.'customer_group WHERE id_customer = '.(int)$id_customer.' )'); $results = $db->executeS($sql); This is outputting a series of "GREKA" values in the `'._DB_PREFIX_.'product_part_number` table at the top of the search results page from the query above: $eligible_products = array(); foreach ($results as $row){ $eligible_products[] = $row['id_product']; echo $row['GREKA']; } What I need it to do is output the "GREKA" value within the tpl file themes/product-list.tpl for that product. This tpl file is using Smarty to output the results of the product search, I need to know how to call the "GREKA" value from the query to the foreach loop. I imagine it would be something like this: {foreach from=$products item=product name=products} {$GREKA} {/foreach} I have tried to put this line of code inside the foreach on the product-list.tpl and it gives me no output , it gives me an error: Code: {$product.GREKA} Error: Notice: Undefined index: GREKA
-
hi im new at prestashop and i need to know a couple things so i can change a query for the search... i need to know how to have the php search for a product id and the product from two different tables ... is this the code that uses the word from the search box to look in the database tables or is this the wrong query ? im just trying to find the query public static function find($id_lang, $expr, $page_number = 1, $page_size = 1, $order_by = 'position', $order_way = 'desc', $ajax = false, $use_cookie = true, Context $context = null) { if (!$context) $context = Context::getContext(); $db = Db::getInstance(_PS_USE_SQL_SLAVE_); // Only use cookie if id_customer is not present if ($use_cookie) $id_customer = $context->customer->id; else $id_customer = 0; // TODO : smart page management if ($page_number < 1) $page_number = 1; if ($page_size < 1) $page_size = 1; if (!Validate::isOrderBy($order_by) || !Validate::isOrderWay($order_way)) return false; $intersect_array = array(); $score_array = array(); $words = explode(' ', Search::sanitize($expr, $id_lang)); foreach ($words as $key => $word) if (!empty($word) && strlen($word) >= (int)Configuration::get('PS_SEARCH_MINWORDLEN')) { $word = str_replace('%', '\\%', $word); $word = str_replace('_', '\\_', $word); $intersect_array[] = 'SELECT si.id_product FROM '._DB_PREFIX_.'search_word sw LEFT JOIN '._DB_PREFIX_.'search_index si ON sw.id_word = si.id_word WHERE sw.id_lang = '.(int)$id_lang.' AND sw.id_shop = '.$context->shop->id.' AND sw.word LIKE '.($word[0] == '-' ? ' \''.pSQL(Tools::substr($word, 1, PS_SEARCH_MAX_WORD_LENGTH)).'%\'' : '\''.pSQL(Tools::substr($word, 0, PS_SEARCH_MAX_WORD_LENGTH)).'%\'' ); if ($word[0] != '-') $score_array[] = 'sw.word LIKE \''.pSQL(Tools::substr($word, 0, PS_SEARCH_MAX_WORD_LENGTH)).'%\''; } else unset($words[$key]); if (!count($words)) return ($ajax ? array() : array('total' => 0, 'result' => array())); $score = ''; if (count($score_array)) $score = ',( SELECT SUM(weight) FROM '._DB_PREFIX_.'search_word sw LEFT JOIN '._DB_PREFIX_.'search_index si ON sw.id_word = si.id_word WHERE sw.id_lang = '.(int)$id_lang.' AND sw.id_shop = '.$context->shop->id.' AND si.id_product = p.id_product AND ('.implode(' OR ', $score_array).') ) position'; $sql = 'SELECT cp.`id_product` FROM `'._DB_PREFIX_.'category_group` cg INNER JOIN `'._DB_PREFIX_.'category_product` cp ON cp.`id_category` = cg.`id_category` INNER JOIN `'._DB_PREFIX_.'category` c ON cp.`id_category` = c.`id_category` INNER JOIN `'._DB_PREFIX_.'product` p ON cp.`id_product` = p.`id_product` '.Shop::addSqlAssociation('product', 'p', false).' WHERE c.`active` = 1 AND product_shop.`active` = 1 AND product_shop.`visibility` IN ("both", "search") AND product_shop.indexed = 1 AND cg.`id_group` '.(!$id_customer ? '= 1' : 'IN ( SELECT id_group FROM '._DB_PREFIX_.'customer_group WHERE id_customer = '.(int)$id_customer.' )'); $results = $db->executeS($sql);
-
- prestashop
- php
-
(and 2 more)
Tagged with:
-
I am new to PHP but have been given some code to split a single text field "Name" in to two seperate fields "First name" and "Last Name" so I can import the data in to my Prestashop v1.4.7.3 website. The script works but the problem I have is that it splits the "Name" field the wrong way around. Example Name - "Mr Dave Simply" is split in to First Name "Simply" and Last Name "Mr Dave" I assume I can just change the results around but I can not figure out how, so am asking for some advise. I have a class.php public static function getName($fullname) { $result = array() ; $result['company'] = '' ; if ( preg_match('/,|\//', $fullname) ) { $parts = preg_split('/,|\//', $fullname) ; $var = trim(substr($parts[0], 0, 31)) ; $result['company'] = trim(substr($parts[1], 0, 31)) ; } else $var = substr($fullname, 0, 31) ; $var = preg_replace('/[0-9!<>,;?=+()@#"�{}_$%:]/', '', $var) ; $var = trim($var) ; $var = substr($var, 0, 31) ; $var1 = explode(' ', $var) ; $sz = sizeof($var1) - 1 ; $lastname = $var1[$sz] ; unset($var1[$sz]) ; $firstname = implode(' ', $var1) ; $firstname = empty($firstname) ? 'unknown' : $firstname ; $lastname = empty($lastname) ? 'unknown' : $lastname ; $result['firstname'] = ucfirst($firstname) ; $result['lastname'] = ucfirst($lastname) ; return($result) ; } and an import.php if ( $account_type == 2 && isset($order->BuyerEmail) ) { $email_address = (string)$order->BuyerEmail ; $customer = new Customer() ; if ( empty($email_address ) ) { echo basename(__FILE__) . ': ' . __LINE__ . ' - ' . $this->l('Couldn\'t add this customer') . ' : ' . $name . '(' . $email_address . ')' ; continue ; } $customer->getByEmail( $email_address ) ; if ( $customer->id ) { $id_customer = $customer->id ; } else { $email_address = (string)$order->BuyerEmail ; $name = Amazon_Address::getAmazonName( (string)$order->Address->Name ) ; $customer->firstname = $name['firstname'] ; $customer->lastname = $name['lastname'] ; $customer->email = $email_address ; $customer->passwd = md5(rand()); if ( ! $customer->add() ) { echo $this->l('Couldn\'t add this customer') . ' : ' . $name . '(' . $email_address . ')' ; } else { $id_customer = $customer->id ; } } } Thanks for your help.