category in product page

  • Posts: 51
  • Thank you received: 0
11 years 5 months ago #76497

hello

i found out how to show the brand on the product page that i asked in a previous post using the following code found in another thread

 <?php
if(!empty($this->element->product_manufacturer_id)){
?>
<tr class="hikashop_product_custom_<?php echo $oneExtraField->field_namekey;?>_line">
<td class="key">
<span id="hikashop_product_custom_name_<?php echo $oneExtraField->field_id;?>" class="hikashop_product_custom_name">
Εκδόσεις
</span>
</td>
<td>
<span id="hikashop_product_custom_value_<?php echo $oneExtraField->field_id;?>" class="hikashop_product_custom_value">
<?php $class = hikashop_get('class.category');
$manufacturer = $class->get($this->element->product_manufacturer_id);
global $Itemid;
$app =& JFactory::getApplication();


echo '<a href="'.hikashop_completeLink('category&task=listing&cid='.$manufacturer->category_id.'&name='.$app->stringURLSafe($manufacturer->category_name).'&Itemid=289').'">'.$manufacturer->category_name.'</a>';

?>
<br />
</span>
</td>
</tr>
<?php
}
?>

Now what i want is your help to modify this code to make it show one subcategory assigned to the product
To the product i have assigned 2 categories like this : main category-category_A main category-category_B-subcategory
so i want to display only the one of them or maybe two (if there where three subcategories) linked to the category description page

the final look of my product page should be like this:

-title
-image

-CATEGORY(linkable)

-price
-extra fields
etc etc

thanx

Last edit: 11 years 5 months ago by Jerome.

Please Log in or Create an account to join the conversation.

  • Posts: 13201
  • Thank you received: 2322
11 years 5 months ago #76598

Hi,

I think that you can try something like that:

<?php
	var_dump(hikashop_currentURL());
	$productClass = hikashop_get('class.product');
	$categories = $productClass->getCategories($this->element->product_id);
	$categoryClass = hikashop_get('class.category');
	$url = ''; //set here the url of your website + menu name + category
	foreach($categories as $category){
		$categoryInfo = $categoryClass->get($category,true);
		echo "<a href='".$url.$categoryInfo->category_name."'>".$categoryInfo->category_name."</a>";
	}
?>

in the view "product / show_default".

The following user(s) said Thank You: gili

Please Log in or Create an account to join the conversation.

  • Posts: 51
  • Thank you received: 0
11 years 5 months ago #76731

$url = ''; //set here the url of your website + menu name + category
for example... www.ubook.gr/ ???????????? what is the menu name and category ????????

Please Log in or Create an account to join the conversation.

  • Posts: 13201
  • Thank you received: 2322
11 years 5 months ago #76882

Hi,

Try this:

<?php
	$url = JURI::base(true)."/index.php?option=com_hikashop&ctrl=category&task=listing";
	$productClass = hikashop_get('class.product');
	$categories = $productClass->getCategories($this->element->product_id);
	$categoryClass = hikashop_get('class.category');
	foreach($categories as $category){
		$categoryInfo = $categoryClass->get($category,true);
		$cid='';
		$name='';
		if(isset($categoryInfo->category_id) && !empty($categoryInfo->category_id)){
			$cid = "&cid=".$categoryInfo->category_id;
			$name = str_replace(' ','-',strtolower($categoryInfo->category_name));
			$name = "&name=".$name;
		}
		$item_id = '';
		global $Itemid;
		if(isset($Itemid) && !empty($Itemid))
			$item_id = "&Itemid=".$Itemid;
		echo "<a href='".$url.$cid.$name.$item_id."'>".$categoryInfo->category_name."</a>";
	}
?>

The following user(s) said Thank You: gili

Please Log in or Create an account to join the conversation.

  • Posts: 51
  • Thank you received: 0
11 years 5 months ago #77027

hello
thats perfect thank you !!!!
to refine it a little and get exactly what i want !! :
imagine we have the root directory with categories... in there there are : BIG_CAT_A and BIG_CAT_B
each of them has its own sub cats .. i d like that script in (2 parts??) to take BIG_CAT_A and show it with other attributes e.g. subcategories and products contained
and take BIG_CAT_B and show its subcategories only with other attributes e.g. just the description of the subcategories
:D :D :D
i hope u understand !!!!
big thanx

Please Log in or Create an account to join the conversation.

  • Posts: 26017
  • Thank you received: 4004
  • MODERATOR
11 years 5 months ago #77246

Hi,

Can you make a screenshot of want you want ?
I understand in the big parts but I don't see it clearly.

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.
The following user(s) said Thank You: gili

Please Log in or Create an account to join the conversation.

  • Posts: 51
  • Thank you received: 0
11 years 5 months ago #77760

hello
screenshot is difficult
the general result is a bookstore that i want the writter to be clickable and show the details of each writer even if i have one or... three writers
and to show ofcourse the category of the book clickable again and when you click it to show all the books of that category
so i thought to make the writters as categories in a general big category (after root) called e.g. WRITTERS and in there to have all the writers and in each product to assign 1-2-3 or as many writers are for the book
and a second big category called e.g. CATEGORIES containing all the categories of the books . SO in the script i could assign manually the id of the big categories and tell to take the first and show this this bla bla and take the second and do the same ...or just hide it (if i dont want to show the categories)
!!!!
any questions ??????? hehhe
thanks :D

Please Log in or Create an account to join the conversation.

  • Posts: 13201
  • Thank you received: 2322
11 years 5 months ago #77773

I think that what you need is something like that:

<?php
	$url = JURI::base(true)."/index.php?option=com_hikashop&ctrl=category&task=listing";
	$productClass = hikashop_get('class.product');
	$categories = $productClass->getCategories($this->element->product_id);
	$categoryClass = hikashop_get('class.category');
        $bookCat = '';
        $writters = '';
	foreach($categories as $category){
		$categoryInfo = $categoryClass->get($category,true);
		$cid='';
		$name='';
		if(isset($categoryInfo->category_id) && !empty($categoryInfo->category_id)){
			$cid = "&cid=".$categoryInfo->category_id;
			$name = str_replace(' ','-',strtolower($categoryInfo->category_name));
			$name = "&name=".$name;
		}
		$item_id = '';
		global $Itemid;
		if(isset($Itemid) && !empty($Itemid))
			$item_id = "&Itemid=".$Itemid;


		if($categoryInfo->category_parent_id == '2') //replace it by the id of CATEGORIES cateogry
		    $bookCat .= "<a href='".$url.$cid.$name.$item_id."'>".$categoryInfo->category_name."</a> ";
		elseif($categoryInfo->category_parent_id == '2') //replace it by the id of WRITTERS category
		    $writters .= "<a href='".$url.$cid.$name.$item_id."'>".$categoryInfo->category_name."</a> ";
	}
        echo "<span class='listCategories'>".$bookCat."</span><br/>";
        echo "<span class='listWriters'>".$writters."</span>";
?>

By this way, you will have two listing, the first one all the categories of the book, and the second one the list of the writers.

Last edit: 11 years 5 months ago by Xavier.
The following user(s) said Thank You: gili

Please Log in or Create an account to join the conversation.

  • Posts: 51
  • Thank you received: 0
11 years 5 months ago #78033

hellooo
you made my day :D thats perfect.. only more one tiny detail :D when you click on the writer it shows you the details i would also like to show all the books that are under him
another thing .. when i click the category i doesn't show all the categories but only 4 . do you know why ??????
thank you

Please Log in or Create an account to join the conversation.

  • Posts: 13201
  • Thank you received: 2322
11 years 5 months ago #78095

Hi,

You already should have the products displayed.
Try to create a category listing menu, even if it's a hidden menu, it should solve the problem.

Could you give me an example for your second thing ?

The following user(s) said Thank You: gili

Please Log in or Create an account to join the conversation.

  • Posts: 51
  • Thank you received: 0
11 years 5 months ago #78112

i already have the default category listing but i also created a new one but nothing . it shows only 4 categories
check here ubook.igrouphost.com/index.php?option=co...106&name=&Itemid=300
this is the product page and click on ΛΟΓΟΤΕΧΝΙΑ
in the top menu you can see "category listing" is the one i created
i also sent you a pm with username and password to access the backend if you need !!!

about the other thing:

as i said there is a book(product) to the book are assigned two main categories a) the category and b) the writers
for the b) the writers (θαναηλακη πολη on the above link) if you click them you can see the category description (cause each writer is a category with image and description) until now which is right. Each writer though has written (been assigned to ) many books(products) so i would like those books to be displayed either on a module or under the description like a product listing. :D
thanks

Please Log in or Create an account to join the conversation.

  • Posts: 13201
  • Thank you received: 2322
11 years 5 months ago #78155

Hi,

To have the products displayed, you just have to replace "ctrl=category" to "ctrl=product" in the previous given code.

The following user(s) said Thank You: gili

Please Log in or Create an account to join the conversation.

  • Posts: 51
  • Thank you received: 0
11 years 5 months ago #78249

helloooo
that worked :D
a problem .. ine the category.. if the book belongs to a subcategory e.g. literature->english literature it should show "english literature" but it shows nothing
if it belongs to literature it shows normal "literature"
whats wrong ???
thanx

Please Log in or Create an account to join the conversation.

  • Posts: 13201
  • Thank you received: 2322
11 years 5 months ago #78306

Hi,

Problem solved, that was because in the code given I was checking the parent_category_id, so it displayed nothing when the parent category were different than the root category.
I just replaced "if($categoryInfo->category_parent_id == '2')" by "if($categoryInfo->category_parent_id != '204')" (204 = writters category)

The following user(s) said Thank You: gili

Please Log in or Create an account to join the conversation.

  • Posts: 51
  • Thank you received: 0
11 years 5 months ago #78397

hello
thank you !! i have another really big problem now
i finally started to import the products and hikashop stops responding
its loading around 4000 brands
100000 categories
and 250000 products
is there any limit or something ? cause i tested it with the first 1000 and it was ok
thanks

Please Log in or Create an account to join the conversation.

  • Posts: 13201
  • Thank you received: 2322
11 years 5 months ago #78421

I think that the problem come from the timeout of your server.
If a page is too long to charge (it's the case while you are uploading a csv) and the time go over the timeout setting of the server then it stops.

I suggest that you made many csv files from your main csv file, to reduce the charge.

The following user(s) said Thank You: gili

Please Log in or Create an account to join the conversation.

  • Posts: 51
  • Thank you received: 0
11 years 5 months ago #78431

i dont upload through csv
i upload with a custom script directly to mysql
after the upload finishes and the db is complete
then i open hikashop, i go to categories-writers
or brands etc .. and i get a blank page
the same in the front end

Please Log in or Create an account to join the conversation.

  • Posts: 13201
  • Thank you received: 2322
11 years 5 months ago #78443

Enable the Joomla debug mode, I think that you have an error while importing.

With the debug mode you should see an error displayed.

The following user(s) said Thank You: gili

Please Log in or Create an account to join the conversation.

  • Posts: 51
  • Thank you received: 0
11 years 5 months ago #78451

Please Log in or Create an account to join the conversation.

  • Posts: 26017
  • Thank you received: 4004
  • MODERATOR
11 years 5 months ago #78462

Hi,

Where did you found this link ?
I don't see any category with this id in your category listing.
Just go on the root directory, show all sub elements and you would see 182 categories.
10009450 and 10009451 have strange numbers but, categories just before are : 204, 201, 200, ...

So, I really don't know what the database entry for the id "1029536", but for HikaShop, it's not a category.

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.
The following user(s) said Thank You: gili

Please Log in or Create an account to join the conversation.

Time to create page: 0.106 seconds
Powered by Kunena Forum