Product sku replaced by another sku

  • Posts: 21
  • Thank you received: 3
6 years 5 days ago #291451

-- url of the page with the problem -- : www.egimotors.it
-- HikaShop version -- : 3.4
-- Joomla version -- : 3.8.6
-- PHP version -- : 7

Hi, in my eshop i have many products SKU replaced by another SKU, for example:

product "belt hd sku 255" replace by "belt hd sku 266" can i redirect automatically from 255 to 266?

thanks in advance

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

  • Posts: 12953
  • Thank you received: 1778
6 years 4 days ago #291465

Hello,

Can you give us more information about how you created and configured your products through some screenshots for example so that we can have a better understanding of your issue ?

Thank you.

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

  • Posts: 21
  • Thank you received: 3
6 years 4 days ago #291524

thank you for your answer... look the example image you can see the old Sku 0450578 and the new SKU 0450251 if I search in my hikashop 0450578 I want to link in the description a link to 0450251.
Is it's possible put a link "these code is old, click here for the right code/sku 0450251"

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

  • Posts: 12953
  • Thank you received: 1778
6 years 3 days ago #291525

Hello,

Your issue is probably coming from the fact that the SKU number that you are trying to apply to your product is already taken by another product so when creating that product Hikashop will either alter the SKU number or tell you that it's already applied to another product.
You should probably change these SKU number directly one by one.

Is it's possible put a link "these code is old, click here for the right code/sku 0450251"


Sure, you can eventually add it through your product description.

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

  • Posts: 21
  • Thank you received: 3
6 years 2 days ago #291601

Thank you for anwser,
now I was able to print the correct code on the screen. I miss the last step build the link with the code that I print. how can i build hikashop url? thank you
i put my code in the file listin_table.php

<?php

$a = $this->row->product_name;
$code   = substr($a, 14);    // 2016
if (preg_match('/SOSTITUITO DA/',$a))

   echo "$code";
   
?>
www.egimotors.it/hika2.jpg

Last edit: 6 years 2 days ago by marcob@polarisitalia.com.

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

  • Posts: 81511
  • Thank you received: 13066
  • MODERATOR
6 years 2 days ago #291610

Hi,

The URL is available in the variable $link
So you can just do like that:

echo '<a href="'.$link.'">'.$code.'</a>';

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

  • Posts: 21
  • Thank you received: 3
6 years 5 hours ago #291654

Hi Nicolas, thank you for your answer.
I would like to link the code product insert of the product name, now i have these php code:

<?php

$a = $this->row->product_name;
$code   = substr($a, 14);    // 2016
if (preg_match('/SOSTITUITO DA/',$a))

   //echo "$code";
   $idsku = $this->row->product_id;
echo "$idsku";
 $hikaurl = "<a href=\"http://www.egimotors.it/index.php?option=com_hikashop&ctrl=product&task=show&cid=$idsku\">Vedi codice</a>";
   echo "$hikaurl";
   
?>

and the product name is "SOSTITUITO DA 0450249 ", how can I get the product_id of the code 0450249?

thanks in advance
Marco

Last edit: 6 years 1 hour ago by marcob@polarisitalia.com.

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

  • Posts: 12953
  • Thank you received: 1778
5 years 11 months ago #291670

Hello,

To do that, you'll ether have to manually search it through your back-end product listing or to use an SQL request through your code if your want it to be dynamic. Something like that:

$db = JFactory::getDBO();
$db->setQuery('SELECT product_id FROM #__hikashop_product WHERE product_code='.$db->Quote($code));
$id = $db->loadResult();
docs.joomla.org/Selecting_data_using_JDatabase

Best regards,
Mohamed Thelji.

Last edit: 6 years 59 minutes ago by nicolas.

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

  • Posts: 21
  • Thank you received: 3
5 years 11 months ago #291943

Hi, good sounds your ideas about the query, i put these code:

<?php
$a = $this->row->product_name;//inizializzo la varibile $a
$code   = substr($a, 14);    // selezione il codice dalla variabile $a
// Get a db connection.
$db = JFactory::getDbo();

// Create a new query object.
$query = $db->getQuery(true);

// Select all records from the user profile table where key begins with "custom.".
// Order it by the ordering field.
$query->select($db->quoteName(array('product_id')));
$query->from($db->quoteName('#_hikashop_product'));
$query->where($db->quoteName('product_code') . ' = '. $db->quote($code));


// Reset the query using our newly populated query object.
$db->setQuery($query);

// Load the results as a list of stdClass objects (see later for more options on retrieving data).
$results = $db->loadAssoc();
$id= $results['product_id'];
if (preg_match('/SOSTITUITO DA/',$a))//stampo il link solo se $a contiene sostituito da
$hikaurl = "<a target=\"_blank\" href=\"http://www.egimotors.it/index.php?option=com_hikashop&ctrl=product&task=show&cid=$id\" id=\"btn-1524838088074\" class=\"sppb-btn  sppb-btn-danger sppb-btn-xs sppb-btn-rounded\"><i class=\"fa fa-angle-double-right\"></i> Vedi codice corretto</a>";
echo "$hikaurl";
?>
and now i have that i want.

Thank you, very much

Regards

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

Time to create page: 0.083 seconds
Powered by Kunena Forum