Jump to content

  • You cannot start a new topic
  • You cannot reply to this topic

Trick: Full path to category during edit product Rate Topic   - - - - -

 
  • soft-solid
  • Junior Member
  • Members
  • Join Date: 19-Apr 10
  • 763 posts

Posted 23 January 2013 - 06:35 PM #1

*
POPULAR

Hello
Here is a simple trick that allows you to show the full path to the category when editing product. This can be useful if you have a complicated and large tree category.
1. First add function to file func.php in directory /addons/my_changes

function fn_my_changes_get_path_category($category_id) {
$id_path = db_get_field("SELECT id_path FROM ?:categories WHERE category_id=".$category_id);
$path = preg_split("/\//",$id_path);
$category_desc = '';
foreach ($path as $path_key => $path_value) {
$temps = db_get_field("SELECT category FROM ?:category_descriptions WHERE category_id=".$path_value." AND lang_code='PL'");
$category_desc .= $temps."/";
} // end foreach
$category_desc = preg_replace("/\/$/","",$category_desc);
return $category_desc;
} // end method fn_my_changes_get_path_category


2. Second
In file /skins/basic/admin/pickers/js_category.tpl change code

  {assign var="default_category" value="`$ldelim`category`$rdelim`"}
{assign var="default_category_id" value="`$ldelim`category_id`$rdelim`"}
{if $first_item || !$category_id}<p class="cm-js-item cm-clone hidden margin-top-clear">{if $hide_input != "Y"}<input class="radio" id="category_rb_{$default_category_id}" type="radio" name="{$radio_input_name}" value="{$default_category_id}">{/if}<label for="category_rb_{$default_category_id}">{$default_category}</label> <a onclick="$.delete_js_item('{$holder}', '{$default_category_id}', 'c'); return false;"><img src="{$images_dir}/icons/delete_icon.gif" width="12" height="11" border="0" alt="{$lang.remove}" align="bottom" /></a></p>{/if}
{if $category_id}<p class="cm-js-item categories-list-item {$extra_class}" id="{$holder}_{$category_id}" {$extra}>{if $hide_input != "Y"}<input class="radio" id="category_radio_button_{$category_id}"{if $main_category == $category_id}checked{/if} type="radio" name="{$radio_input_name}" value="{$category_id}" />{/if}{if $category_data.company_id}<span class="categories-store-name">{include file="views/companies/components/company_name.tpl" company_name=$category_data.company_name company_id=$category_data.company_id}</span>{/if}<label for="category_radio_button_{$category_id}">{$category|escape}</label>{if !"COMPANY_ID"|defined || ("COMPANY_ID"|defined && ($category_data.company_id == $smarty.const.COMPANY_ID || $smarty.const.COMPANY_ID == $owner_company_id))}<a onclick="$.delete_js_item('{$holder}', '{$category_id}', 'c'); return false;" class="icon-delete-small"><img src="{$images_dir}/icons/delete_icon.gif" width="12" height="11" border="0" alt="{$lang.remove}" title="{$lang.remove}" align="bottom" /></a>{/if}</p>{/if}


change on

  {assign var="default_category" value="`$ldelim`category`$rdelim`"}
{assign var="default_category_id" value="`$ldelim`category_id`$rdelim`"}
{assign var="path_category" value=$category_id|fn_my_changes_get_path_category}

{if $first_item || !$category_id}<p class="cm-js-item cm-clone hidden margin-top-clear">{if $hide_input != "Y"}<input class="radio" id="category_rb_{$default_category_id}" type="radio" name="{$radio_input_name}" value="{$default_category_id}">{/if}<label for="category_rb_{$default_category_id}">{$default_category}</label> <a onclick="$.delete_js_item('{$holder}', '{$default_category_id}', 'c'); return false;"><img src="{$images_dir}/icons/delete_icon.gif" width="12" height="11" border="0" alt="{$lang.remove}" align="bottom" /></a></p>{/if}
{if $category_id}<p class="cm-js-item categories-list-item {$extra_class}" id="{$holder}_{$category_id}" {$extra}>{if $hide_input != "Y"}<input class="radio" id="category_radio_button_{$category_id}"{if $main_category == $category_id}checked{/if} type="radio" name="{$radio_input_name}" value="{$category_id}" />{/if}{if $category_data.company_id}<span class="categories-store-name">{include file="views/companies/components/company_name.tpl" company_name=$category_data.company_name company_id=$category_data.company_id}</span>{/if}<label for="category_radio_button_{$category_id}">

{$path_category}

</label>{if !"COMPANY_ID"|defined || ("COMPANY_ID"|defined && ($category_data.company_id == $smarty.const.COMPANY_ID || $smarty.const.COMPANY_ID == $owner_company_id))}<a onclick="$.delete_js_item('{$holder}', '{$category_id}', 'c'); return false;" class="icon-delete-small"><img src="{$images_dir}/icons/delete_icon.gif" width="12" height="11" border="0" alt="{$lang.remove}" title="{$lang.remove}" align="bottom" /></a>{/if}</p>{/if}


Below effect:

Posted Image


Regards
Robert Diak
Team of SoftSolid
cs-cart.pl

 
  • vidan
  • Senior Member
  • Members
  • Join Date: 11-Jan 10
  • 373 posts

Posted 23 January 2013 - 09:54 PM #2

Wow thanks for this.

 
  • soft-solid
  • Junior Member
  • Members
  • Join Date: 19-Apr 10
  • 763 posts

Posted 25 January 2013 - 12:57 PM #3

Hello.
The following correction function, because when you add the product generated mistake.

function fn_my_changes_get_path_category($category_id) {
if(!empty($category_id)) {
$id_path = db_get_field("SELECT id_path FROM ?:categories WHERE category_id=".$category_id);
$path = preg_split("/\//",$id_path);
$category_desc = '';
foreach ($path as $path_key => $path_value) {
if(!empty($path_value)) {
$temps = db_get_field("SELECT category FROM ?:category_descriptions WHERE category_id=".$path_value." AND lang_code='PL'");
$category_desc .= $temps."/";
} // end if
} // end foreach

$category_desc = preg_replace("/\/$/","",$category_desc);
return $category_desc;
} // end if
} // end method fn_my_changes_get_path_category


Regards.
Robert Diak
Team of SoftSolid
cs-cart.pl

 
  • soft-solid
  • Junior Member
  • Members
  • Join Date: 19-Apr 10
  • 763 posts

Posted 12 February 2013 - 09:47 PM #4

Hello.
The following correction function, because when you add the product generated mistake.

function fn_my_changes_get_path_category($category_id) {
if(!empty($category_id)) {
$id_path = db_get_field("SELECT id_path FROM ?:categories WHERE category_id=".$category_id);
$path = preg_split("/\//",$id_path);
$category_desc = '';
foreach ($path as $path_key => $path_value) {
if(!empty($path_value)) {
$temps = db_get_field("SELECT category FROM ?:category_descriptions WHERE category_id=".$path_value." AND lang_code='".CART_LANGUAGE."'");
$category_desc .= $temps."/";
} // end if
} // end foreach
$category_desc = preg_replace("/\/$/","",$category_desc);
return $category_desc;
} // end if
} // end method fn_my_changes_get_path_category


Regards
Robert Diak
Team of SoftSolid
cs-cart.pl

 
  • Hungryweb
  • Senior Member
  • Authorized Reseller
  • Join Date: 10-Feb 12
  • 1248 posts

Posted 22 February 2013 - 01:07 PM #5

Very useful trick, it should be added into cs-cart by default

---
Valentin

 
  • Magpie Don
  • Senior Member
  • Members
  • Join Date: 01-Apr 09
  • 814 posts

Posted 22 February 2013 - 06:55 PM #6

After applying this change:
On Save of product, I get a page with "continue", hyperlinked to dispatch=products.update. After approx 10 seconds the process continues as normal.
This is new - I never had this delay w/continue page on a product update before. Is this normal behavior?

It appears to be caused after I created func.php in the addon/my_changes folder.

This is the entire contents of func.php:
<?php
if ( !defined('AREA') ) { die('Access denied'); }
function fn_my_changes_get_path_category($category_id)
{
if(!empty($category_id))
{
$id_path = db_get_field("SELECT id_path FROM ?:categories WHERE category_id=".$category_id);
$path = preg_split("/\//",$id_path);
$category_desc = '';
foreach ($path as $path_key => $path_value)
{
if(!empty($path_value))
{
$temps = db_get_field("SELECT category FROM ?:category_descriptions WHERE category_id=".$path_value." AND lang_code='".CART_LANGUAGE."'");
$category_desc .= $temps."/";
} // end if
} // end foreach
$category_desc = preg_replace("/\/$/","",$category_desc);
return $category_desc;
} // end if
} // end method fn_my_changes_get_path_category
?>

CS-Cart Ultimate ver 4.3.5


 
  • soft-solid
  • Junior Member
  • Members
  • Join Date: 19-Apr 10
  • 763 posts

Posted 22 February 2013 - 07:49 PM #7

Hello

If you can send me an ftp access and the panel, we will check it.
This should not be happening.

Regards
Robert Diak
Team of SoftSolid
cs-cart.pl

 
  • Hungryweb
  • Senior Member
  • Authorized Reseller
  • Join Date: 10-Feb 12
  • 1248 posts

Posted 22 February 2013 - 11:56 PM #8

@Magpie Don
please check in the file addon/my_changes/func.php after
?>
you have blank line/s, this is the reason why continue message appear, delete all the blank line, and check also other modified php files

---
Valentin

 
  • soft-solid
  • Junior Member
  • Members
  • Join Date: 19-Apr 10
  • 763 posts

Posted 23 February 2013 - 06:27 AM #9

Hello.
Yes Vali's right. The cause can be any white space in the file func.php

Regards
Robert Diak.
Team of SoftSolid
cs-cart.pl

 
  • Magpie Don
  • Senior Member
  • Members
  • Join Date: 01-Apr 09
  • 814 posts

Posted 24 February 2013 - 02:31 AM #10

Yes, thank you. That was the cause. My mistake.
Very useful modification since CS-Cart store now shows products in sub-categories.

What we need is to move the "Search in Sub-categories" checkbox out of the Admin's advanced search form and into the main search form.

CS-Cart Ultimate ver 4.3.5


 
  • sertaconay
  • Member
  • Members
  • Join Date: 29-Dec 11
  • 18 posts

Posted 16 July 2013 - 02:15 PM #11

Hello.

Do you know how we can do this trick in version 4?

 
  • Hungryweb
  • Senior Member
  • Authorized Reseller
  • Join Date: 10-Feb 12
  • 1248 posts

Posted 17 July 2013 - 02:22 PM #12

Hi @sertaconay

For cs-cart 4 you need to follow steps bellow:
  • copy to file app/addons/my_changes/func.php
    	<?php
    	/*****************************************************************
    	*															    *
    	*   (c) 2013 HungryWeb.net | Support at Yum [at] hungryweb.net   *
    	*															    *
    	*****************************************************************/   	
    if (!defined('BOOTSTRAP')) { die('Access denied'); }	function fn_my_changes_get_path_category($category_id) {
    	if(!empty($category_id)) {
    	  $id_path = db_get_field("SELECT id_path FROM ?:categories WHERE category_id=".$category_id);
    	  $path = preg_split("/\//",$id_path);
    	  $category_desc = '';
    	  foreach ($path as $path_key => $path_value) {
    	   if(!empty($path_value)) {
    		    $temps = db_get_field("SELECT category FROM ?:category_descriptions WHERE category_id=".$path_value." AND lang_code='".CART_LANGUAGE."'");
    		    $category_desc .= $temps." / ";
    	   } // end if
    	  } // end foreach
    	  $category_desc = preg_replace("/ \/ $/","",$category_desc);
    	  return $category_desc;
    	} // end if
    	} // end method fn_my_changes_get_path_category   
    
  • on file design/backend/templates/pickers/categories/js.tpl
after:
		{assign var="default_category" value="`$ldelim`category`$rdelim`"}
		{assign var="default_category_id" value="`$ldelim`category_id`$rdelim`"}

add:
		{** add by hungryweb.net **}
		{assign var="default_category" value=$category_id|fn_my_changes_get_path_category}
		{assign var="category" value=$default_category}

[ Tested on CS-Cart: version 4.0.1 ULTIMATE ]

I hope that helps,

---
Valentin