Jump to content

saracoratello

Members
  • Posts

    11
  • Joined

  • Last visited

saracoratello's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. My problem is that this attributes are hidden when im using search engine ( i modified controller) and layered block navigation. Any ideas why ?
  2. OK i made it wirh a little help od this forum posts history! add to blockspecials.php this code: public function getProductAttributeCombinations($products) { $combinations = array(); foreach($products as $product) { // load product object $product = new Product ($product['id_product'], $this->context->language->id); // get the product combinations data // create array combinations with key = id_product $combinations[$product->id] = $product->getAttributeCombinations($this->context->language->id); } return $combinations; } public function hookRightColumn($params) { if (Configuration::get('PS_CATALOG_MODE')) return; // We need to create multiple caches because the products are sorted randomly $random = date('Ymd').'|'.round(rand(1, max(Configuration::get('BLOCKSPECIALS_NB_CACHES'), 1))); if (!Configuration::get('BLOCKSPECIALS_NB_CACHES') || !$this->isCached('blockspecials.tpl', $this->getCacheId('blockspecials|'.$random))) { if (!($specials = Product::getPricesDrop((int)$params['cookie']->id_lang, 0, 5)) && !Configuration::get('PS_BLOCK_SPECIALS_DISPLAY')) return; $produkty = Product::getPricesDrop((int)$params['cookie']->id_lang, 0, 5); $combinations = $this->getProductAttributeCombinations($produkty); $this->smarty->assign(array( 'specials' => $specials, 'combinations' => $combinations, 'mediumSize' => Image::getSize(ImageType::getFormatedName('medium')), )); } and in theme {foreach from=$combinations key=k item=comb} {if $k == $special.id_product} {$attr.attribute_name} {/if} {/foreach}
  3. Hi, i have prestashop 1.5.6.2. I want to display products attributes (color) in product listing of this module, but i see that it is not default. Anybody know how to do this ? Maybe some tips ? Thanks in advance.
  4. Hello I made custom module, and i want to display in it sorted by product features. I'm displaying product in this way: $products = Product::getProducts($cookie->id_lang, 0, NULL,'id_product', 'ASC'); $this->smarty->assign(array( 'products' => $products )); return $this->display(__FILE__, 'tousnossejours.tpl'); but i do not have any idea how to set features for product in this list - maybe you have some tips - thanks.
  5. Hi all, i want to add extra logo to my prestashop 1.5, I modified file /controllers/admin/AdminManufacturersController.php this way: <?php /* * 2007-2013 PrestaShop * * NOTICE OF LICENSE * * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.txt. * It is also available through the world-wide-web at this URL: * http://opensource.org/licenses/osl-3.0.php * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to [email protected] so we can send you a copy immediately. * * DISCLAIMER * * Do not edit or add to this file if you wish to upgrade PrestaShop to newer * versions in the future. If you wish to customize PrestaShop for your * needs please refer to http://www.prestashop.com for more information. * * @author PrestaShop SA <[email protected]> * @copyright 2007-2013 PrestaShop SA * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * International Registered Trademark & Property of PrestaShop SA */ class AdminManufacturersControllerCore extends AdminController { /** @var array countries list */ protected $countries_array = array(); public function __construct() { $this->table = 'manufacturer'; $this->className = 'Manufacturer'; $this->lang = false; $this->deleted = false; $this->allow_export = true; $this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?'))); $this->context = Context::getContext(); $this->fieldImageSettings = array( 'logo' => array( 'name' => 'logo', 'dir' => 'm', ), 'logo2' => array( 'name' => 'logo2', 'dir' => 'm2', ), ); $this->fields_list = array( 'id_manufacturer' => array( 'title' => $this->l('ID'), 'width' => 25 ), 'logo' => array( 'title' => $this->l('Logo'), 'image' => 'm', 'orderby' => false, 'search' => false, 'width' => 150, 'align' => 'center', ), 'logo2' => array( 'title' => $this->l('Logo2'), 'image' => 'm2', 'orderby' => false, 'search' => false, 'width' => 150, 'align' => 'center', ), 'name' => array( 'title' => $this->l('Name'), 'width' => 'auto' ), 'addresses' => array( 'title' => $this->l('Addresses'), 'width' => 20, 'align' => 'center', 'havingFilter' => true ), 'products' => array( 'title' => $this->l('Products:'), 'havingFilter' => true, 'width' => 20, 'align' => 'center', ), 'active' => array( 'title' => $this->l('Enabled'), 'width' => 70, 'active' => 'status', 'type' => 'bool', 'align' => 'center', 'orderby' => false ) ); parent::__construct(); } public function setMedia() { parent::setMedia(); $this->addJqueryUi('ui.widget'); $this->addJqueryPlugin('tagify'); } public function initListManufacturer() { $this->addRowAction('view'); $this->addRowAction('edit'); $this->addRowAction('delete'); $this->_select = ' COUNT(`id_product`) AS `products`, ( SELECT COUNT(ad.`id_manufacturer`) as `addresses` FROM `'._DB_PREFIX_.'address` ad WHERE ad.`id_manufacturer` = a.`id_manufacturer` AND ad.`deleted` = 0 GROUP BY ad.`id_manufacturer`) as `addresses`'; $this->_join = 'LEFT JOIN `'._DB_PREFIX_.'product` p ON (a.`id_manufacturer` = p.`id_manufacturer`)'; $this->_group = 'GROUP BY a.`id_manufacturer`'; $this->context->smarty->assign('title_list', $this->l('List of manufacturers:')); $this->content .= parent::renderList(); } public function initListManufacturerAddresses() { $this->toolbar_title = $this->l('Addresses'); // reset actions and query vars $this->actions = array(); unset($this->fields_list, $this->_select, $this->_join, $this->_group, $this->_filterHaving, $this->_filter); $this->table = 'address'; $this->identifier = 'id_address'; $this->deleted = true; $this->_orderBy = null; $this->addRowAction('editaddresses'); $this->addRowAction('delete'); // test if a filter is applied for this list if (Tools::isSubmit('submitFilter'.$this->table) || $this->context->cookie->{'submitFilter'.$this->table} !== false) $this->filter = true; // test if a filter reset request is required for this list if (isset($_POST['submitReset'.$this->table])) $this->action = 'reset_filters'; else $this->action = ''; // Sub tab addresses $countries = Country::getCountries($this->context->language->id); foreach ($countries as $country) $this->countries_array[$country['id_country']] = $country['name']; $this->fields_list = array( 'id_address' => array( 'title' => $this->l('ID'), 'width' => 25 ), 'manufacturer_name' => array( 'title' => $this->l('Manufacturer'), 'width' => 'auto' ), 'firstname' => array( 'title' => $this->l('First name'), 'width' => 80 ), 'lastname' => array( 'title' => $this->l('Last name'), 'width' => 100, 'filter_key' => 'a!name' ), 'postcode' => array( 'title' => $this->l('Zip Code/Postal Code'), 'align' => 'right', 'width' => 50 ), 'city' => array( 'title' => $this->l('City'), 'width' => 150 ), 'country' => array( 'title' => $this->l('Country'), 'width' => 100, 'type' => 'select', 'list' => $this->countries_array, 'filter_key' => 'cl!id_country' ) ); $this->_select = 'cl.`name` as country, m.`name` AS manufacturer_name'; $this->_join = ' LEFT JOIN `'._DB_PREFIX_.'country_lang` cl ON (cl.`id_country` = a.`id_country` AND cl.`id_lang` = '.(int)$this->context->language->id.') '; $this->_join .= ' LEFT JOIN `'._DB_PREFIX_.'manufacturer` m ON (a.`id_manufacturer` = m.`id_manufacturer`)'; $this->_where = 'AND a.`id_customer` = 0 AND a.`id_supplier` = 0 AND a.`id_warehouse` = 0'; $this->context->smarty->assign('title_list', $this->l('Manufacturers addresses:')); // call postProcess() for take care about actions and filters $this->postProcess(); $this->initToolbar(); $this->content .= parent::renderList(); } public function renderList() { $this->initListManufacturer(); $this->initListManufacturerAddresses(); } /** * Display editaddresses action link * @param string $token the token to add to the link * @param int $id the identifier to add to the link * @return string */ public function displayEditaddressesLink($token = null, $id) { if (!array_key_exists('editaddresses', self::$cache_lang)) self::$cache_lang['editaddresses'] = $this->l('Edit Adresses'); $this->context->smarty->assign(array( 'href' => self::$currentIndex. '&'.$this->identifier.'='.$id. '&editaddresses&token='.($token != null ? $token : $this->token), 'action' => self::$cache_lang['editaddresses'], )); return $this->context->smarty->fetch('helpers/list/list_action_edit.tpl'); } public function renderForm() { $this->fields_form = array( 'tinymce' => true, 'legend' => array( 'title' => $this->l('Manufacturers:'), 'image' => '../img/admin/manufacturers.gif' ), 'input' => array( array( 'type' => 'text', 'label' => $this->l('Name:'), 'name' => 'name', 'size' => 40, 'required' => true, 'hint' => $this->l('Invalid characters:').' <>;=#{}' ), array( 'type' => 'textarea', 'label' => $this->l('Short description:'), 'name' => 'short_description', 'lang' => true, 'cols' => 60, 'rows' => 10, 'class' => 'rte', 'hint' => $this->l('Invalid characters:').' <>;=#{}' ), array( 'type' => 'textarea', 'label' => $this->l('Description:'), 'name' => 'description', 'lang' => true, 'cols' => 60, 'rows' => 10, 'class' => 'rte', 'hint' => $this->l('Invalid characters:').' <>;=#{}' ), array( 'type' => 'file', 'label' => $this->l('Logo:'), 'name' => 'logo', 'display_image' => true, 'desc' => $this->l('Upload a manufacturer logo from your computer.') ), array( 'type' => 'file', 'label' => $this->l('Logo 2:'), 'name' => 'logo2', 'display_image' => true, 'desc' => $this->l('Upload a 2 manufacturer logo from your computer.') ), array( 'type' => 'text', 'label' => $this->l('Meta title:'), 'name' => 'meta_title', 'lang' => true, 'hint' => $this->l('Forbidden characters:').' <>;=#{}' ), array( 'type' => 'text', 'label' => $this->l('Meta description:'), 'name' => 'meta_description', 'lang' => true, 'hint' => $this->l('Forbidden characters:').' <>;=#{}' ), array( 'type' => 'tags', 'label' => $this->l('Meta keywords:'), 'name' => 'meta_keywords', 'lang' => true, 'hint' => $this->l('Forbidden characters:').' <>;=#{}', 'desc' => $this->l('To add "tags," click inside the field, write something, and then press "Enter."') ), array( 'type' => 'radio', 'label' => $this->l('Enable:'), 'name' => 'active', 'required' => false, 'class' => 't', 'is_bool' => true, 'values' => array( array( 'id' => 'active_on', 'value' => 1, 'label' => $this->l('Enabled') ), array( 'id' => 'active_off', 'value' => 0, 'label' => $this->l('Disabled') ) ) ) ) ); if (!($manufacturer = $this->loadObject(true))) return; if (Shop::isFeatureActive()) { $this->fields_form['input'][] = array( 'type' => 'shop', 'label' => $this->l('Shop association:'), 'name' => 'checkBoxShopAsso', ); } $this->fields_form['submit'] = array( 'title' => $this->l('Save '), 'class' => 'button' ); $image = ImageManager::thumbnail(_PS_MANU_IMG_DIR_.'/'.$manufacturer->id.'.jpg', $this->table.'_'.(int)$manufacturer->id.'.'.$this->imageType, 350, $this->imageType, true); $this->fields_value = array( 'image' => $image ? $image : false, 'size' => $image ? filesize(_PS_MANU_IMG_DIR_.'/'.$manufacturer->id.'.jpg') / 1000 : false ); foreach ($this->_languages as $language) { $this->fields_value['short_description_'.$language['id_lang']] = htmlentities(stripslashes($this->getFieldValue( $manufacturer, 'short_description', $language['id_lang'] )), ENT_COMPAT, 'UTF-8'); $this->fields_value['description_'.$language['id_lang']] = htmlentities(stripslashes($this->getFieldValue( $manufacturer, 'description', $language['id_lang'] )), ENT_COMPAT, 'UTF-8'); } return parent::renderForm(); } public function renderFormAddress() { // Change table and className for addresses $this->table = 'address'; $this->className = 'Address'; $id_address = Tools::getValue('id_address'); // Create Object Address $address = new Address($id_address); $form = array( 'legend' => array( 'title' => $this->l('Addresses'), 'image' => '../img/admin/contact.gif' ) ); if (!$address->id_manufacturer || !Manufacturer::manufacturerExists($address->id_manufacturer)) $form['input'][] = array( 'type' => 'select', 'label' => $this->l('Choose the manufacturer:'), 'name' => 'id_manufacturer', 'options' => array( 'query' => Manufacturer::getManufacturers(), 'id' => 'id_manufacturer', 'name' => 'name' ) ); else { $form['input'][] = array( 'type' => 'text', 'label' => $this->l('Manufacturer:'), 'name' => 'name', 'disabled' => true, ); $form['input'][] = array( 'type' => 'hidden', 'name' => 'id_manufacturer' ); } $form['input'][] = array( 'type' => 'hidden', 'name' => 'alias', ); $form['input'][] = array( 'type' => 'text', 'label' => $this->l('Last name:'), 'name' => 'lastname', 'size' => 33, 'required' => true, 'hint' => $this->l('Invalid characters:').' 0-9!<>,;?=+()@#"�{}_$%:' ); $form['input'][] = array( 'type' => 'text', 'label' => $this->l('First name:'), 'name' => 'firstname', 'size' => 33, 'required' => true, 'hint' => $this->l('Invalid characters:').' 0-9!<>,;?=+()@#"�{}_$%:' ); $form['input'][] = array( 'type' => 'text', 'label' => $this->l('Address:'), 'name' => 'address1', 'size' => 33, 'required' => true, ); $form['input'][] = array( 'type' => 'text', 'label' => $this->l('Address (2):'), 'name' => 'address2', 'size' => 33, 'required' => false, ); $form['input'][] = array( 'type' => 'text', 'label' => $this->l('Zip Code/Postal Code'), 'name' => 'postcode', 'size' => 33, 'required' => false, ); $form['input'][] = array( 'type' => 'text', 'label' => $this->l('City:'), 'name' => 'city', 'size' => 33, 'required' => true, ); $form['input'][] = array( 'type' => 'select', 'label' => $this->l('Country:'), 'name' => 'id_country', 'required' => false, 'default_value' => (int)$this->context->country->id, 'options' => array( 'query' => Country::getCountries($this->context->language->id), 'id' => 'id_country', 'name' => 'name', ) ); $form['input'][] = array( 'type' => 'select', 'label' => $this->l('State:'), 'name' => 'id_state', 'required' => false, 'options' => array( 'query' => array(), 'id' => 'id_state', 'name' => 'name' ) ); $form['input'][] = array( 'type' => 'text', 'label' => $this->l('Home phone:'), 'name' => 'phone', 'size' => 33, 'required' => false, ); $form['input'][] = array( 'type' => 'text', 'label' => $this->l('Mobile phone:'), 'name' => 'phone_mobile', 'size' => 33, 'required' => false, ); $form['input'][] = array( 'type' => 'textarea', 'label' => $this->l('Other:'), 'name' => 'other', 'cols' => 36, 'rows' => 4, 'required' => false, 'hint' => $this->l('Forbidden characters:').' <>;=#{}' ); $form['submit'] = array( 'title' => $this->l('Save '), 'class' => 'button' ); $this->fields_value = array( 'name' => Manufacturer::getNameById($address->id_manufacturer), 'alias' => 'manufacturer', 'id_country' => Configuration::get('PS_COUNTRY_DEFAULT') ); $this->initToolbar(); $this->fields_form[0]['form'] = $form; $this->getlanguages(); $helper = new HelperForm(); $helper->currentIndex = self::$currentIndex; $helper->token = $this->token; $helper->table = $this->table; $helper->identifier = $this->identifier; $helper->title = $this->l('Edit Addresses'); $helper->id = $address->id; $helper->toolbar_scroll = true; $helper->languages = $this->_languages; $helper->default_form_language = $this->default_form_language; $helper->allow_employee_form_lang = $this->allow_employee_form_lang; $helper->fields_value = $this->getFieldsValue($address); $helper->toolbar_btn = $this->toolbar_btn; $this->content .= $helper->generateForm($this->fields_form); } /** * AdminController::initToolbar() override * @see AdminController::initToolbar() * */ public function initToolbar() { switch ($this->display) { case 'editaddresses': case 'addaddress': $this->toolbar_btn['save'] = array( 'href' => '#', 'desc' => $this->l('Save') ); // Default cancel button - like old back link if (!isset($this->no_back) || $this->no_back == false) { $back = Tools::safeOutput(Tools::getValue('back', '')); if (empty($back)) $back = self::$currentIndex.'&token='.$this->token; $this->toolbar_btn['cancel'] = array( 'href' => $back, 'desc' => $this->l('Cancel') ); } break; default: parent::initToolbar(); $this->toolbar_btn['import'] = array( 'href' => $this->context->link->getAdminLink('AdminImport', true).'&import_type='.$this->table, 'desc' => $this->l('Import') ); } } public function renderView() { if (!($manufacturer = $this->loadObject())) return; $addresses = $manufacturer->getAddresses($this->context->language->id); $products = $manufacturer->getProductsLite($this->context->language->id); $total_product = count($products); for ($i = 0; $i < $total_product; $i++) { $products[$i] = new Product($products[$i]['id_product'], false, $this->context->language->id); $products[$i]->loadStockData(); /* Build attributes combinations */ $combinations = $products[$i]->getAttributeCombinations($this->context->language->id); foreach ($combinations as $k => $combination) { $comb_array[$combination['id_product_attribute']]['reference'] = $combination['reference']; $comb_array[$combination['id_product_attribute']]['ean13'] = $combination['ean13']; $comb_array[$combination['id_product_attribute']]['upc'] = $combination['upc']; $comb_array[$combination['id_product_attribute']]['quantity'] = $combination['quantity']; $comb_array[$combination['id_product_attribute']]['attributes'][] = array( $combination['group_name'], $combination['attribute_name'], $combination['id_attribute'] ); } if (isset($comb_array)) { foreach ($comb_array as $key => $product_attribute) { $list = ''; foreach ($product_attribute['attributes'] as $attribute) $list .= $attribute[0].' - '.$attribute[1].', '; $comb_array[$key]['attributes'] = rtrim($list, ', '); } isset($comb_array) ? $products[$i]->combination = $comb_array : ''; unset($comb_array); } } $this->tpl_view_vars = array( 'manufacturer' => $manufacturer, 'addresses' => $addresses, 'products' => $products, 'stock_management' => Configuration::get('PS_STOCK_MANAGEMENT'), 'shopContext' => Shop::getContext(), ); return parent::renderView(); } public function initContent() { // toolbar (save, cancel, new, ..) $this->initToolbar(); if ($this->display == 'editaddresses' || $this->display == 'addaddress') $this->content .= $this->renderFormAddress(); else if ($this->display == 'edit' || $this->display == 'add') { if (!$this->loadObject(true)) return; $this->content .= $this->renderForm(); } else if ($this->display == 'view') { // Some controllers use the view action without an object if ($this->className) $this->loadObject(true); $this->content .= $this->renderView(); } else if (!$this->ajax) { $this->content .= $this->renderList(); $this->content .= $this->renderOptions(); } $this->context->smarty->assign(array( 'content' => $this->content, 'url_post' => self::$currentIndex.'&token='.$this->token, )); } /** * AdminController::init() override * @see AdminController::init() */ public function init() { parent::init(); if (Tools::isSubmit('editaddresses')) $this->display = 'editaddresses'; else if (Tools::isSubmit('addaddress')) $this->display = 'addaddress'; else if (Tools::isSubmit('submitAddaddress')) $this->action = 'save'; else if (Tools::isSubmit('deleteaddress')) $this->action = 'delete'; } public function initProcess() { if (Tools::getValue('submitAddaddress') || Tools::isSubmit('deleteaddress') || Tools::isSubmit('submitBulkdeleteaddress')) { $this->table = 'address'; $this->className = 'Address'; $this->identifier = 'id_address'; $this->deleted = true; } parent::initProcess(); } protected function afterImageUpload() { $res = true; /* Generate image with differents size */ if (($id_manufacturer = (int)Tools::getValue('id_manufacturer')) && isset($_FILES) && count($_FILES) && file_exists(_PS_MANU_IMG_DIR_.$id_manufacturer.'.jpg')) { $images_types = ImageType::getImagesTypes('manufacturers'); foreach ($images_types as $k => $image_type) { $res &= ImageManager::resize( _PS_MANU_IMG_DIR_.$id_manufacturer.'.jpg', _PS_MANU_IMG_DIR_.$id_manufacturer.'-'.stripslashes($image_type['name']).'.jpg', (int)$image_type['width'], (int)$image_type['height'] ); } } if (!$res) $this->errors[] = Tools::displayError('Unable to resize one or more of your pictures.'); return $res; } } where my second logo is named logo2 -> i want it to be uploaded to m2 folder, then i can with code Problem is that this logo2 is always displaying first logo, so i have two times in Image field first logo, and none of my new. Any ideas what more should i do ?
  6. Hello, I have prestashop 1.4.7 My problem is that i want to show on category pages two images, not only one. And i do not have too much idea how to do this. adding this code to Controller/CategoryController.php in process function $image_array=array(); for($i=0;$i<count($cat_products);$i++) { $image_array[$i]= $this->category->getProductsimg($cat_products[$i]['id_product']); } self::$smarty->assign('productimg',(isset($image_array) AND $image_array) ? $image_array : NULL); and this into my-theme/product-list.tpl {foreach from=$productimg key=key1 item=pimage} {foreach from=$pimage key=key2 item=pimage2} {if $product.id_product==$pimage2.id_product} <img src="{$link->getImageLink($product.link_rewrite,$product.id_product|cat:"-"|cat:$pimage2.id_image, 'home')}" alt="{$product.legend|escape:'htmlall':'UTF-8'}" {if isset($homeSize)} width="{$homeSize.width}" height="{$homeSize.height}"{/if} class="{$key2}" /> {/if} {/foreach} {/foreach} is not helping, and i do not have any other ideas. And if some of you know how to set custom thumbnail ( i want crop image on my own) in this view, it will be awesome!
  7. Yes, this is exactly what i need, but unfortunately it is not working in my PrestaShop - it is not showing any images. i Have PrestaShop™ 1.4.7.0. Does any one know how can i do this work ? Or just show second image on this list - i will hande roll over effect, just need to display more than one picture on product list.
  8. Hi, I have Prestashop 4.6.1 and have trouble with 'Add to cart' button on product page. But only on Safari and Chrome - Firefox works properly. When i click this button it stays disable, and cart is not updated. I do not know what else can i do. I know that was the trouble on prestashop 4.5.1 but i'm not sure how i can solve this. Anyone has the troble like this ?
  9. Yes! Im about 2nd method. But unfortunatelly i have no idea how could i do this - im not so into .php - i was trying do this on my own - but all i get is one big error.
  10. Hi there, I want change prestashop new products module hook function to show products from only one category. Does anyone have idea how can i do this ? I know how to do this by tpl and {$newproduct.category} var, but i find this method as "volatile". Here are default hook function from blocknewproducts.php : public function hookHome($params) { global $smarty; $newProducts = Product::getNewProducts((int)($params['cookie']->id_lang), 0, (int)(Configuration::get('NEW_PRODUCTS_NBR'))); if (!$newProducts AND !Configuration::get('PS_BLOCK_NEWPRODUCTS_DISPLAY')) return; $smarty->assign(array('new_products' => $newProducts, 'mediumSize' => Image::getSize('medium'))); return $this->display(__FILE__, 'blocknewproducts.tpl'); } Thanks!
×
×
  • Create New...