s10e06 - Soft Redirect (Products) SUPPORT / QUESTIONS / CHAT
-
14Steve14
- Senior Contributor
- Posts: 921
- Joined: Fri Oct 25, 2019 7:01 pm
- Phoenix Version: v1.0.9.1
- Has thanked: 17 times
- Been thanked: 103 times
s10e06 - Soft Redirect (Products) SUPPORT / QUESTIONS / CHAT
Addon:
Allows shopowner to easily redirect a product to another.
Download:
viewtopic.php?f=28&t=1024
--
When we discontinue items, or have products out of stock for a long time, we always use an older version of this mod. It saves customers time and stops them seeing a blank screen if they searched for a particular product. We do get sales from using it, so it must be good to use.
Allows shopowner to easily redirect a product to another.
Download:
viewtopic.php?f=28&t=1024
--
When we discontinue items, or have products out of stock for a long time, we always use an older version of this mod. It saves customers time and stops them seeing a blank screen if they searched for a particular product. We do get sales from using it, so it must be good to use.
Tags:
-
radhavallabh
- Senior Contributor
- Posts: 466
- Joined: Tue Oct 27, 2020 4:09 am
- Phoenix Version: 1.1.0.6
- Has thanked: 29 times
- Been thanked: 3 times
Re: s10e06 - Soft Redirect (Products)
Hi;
I get below error on the and product edit page does not load properly-
PHP Fatal error: Uncaught TypeError: Argument 3 passed to Select::__construct() must be of the type array, null given, called in /xx/xx/includes/hooks/admin/catalog/soft_redirect.php on line 37 and defined in /xx/xx/includes/system/versioned/1.0.8.1/select.php:32
Stack trace:
#0 /xx/xx/includes/hooks/admin/catalog/soft_redirect.php(37): Select-
20220214T072347: xx/xx/admin/index.php
PHP Fatal error: Uncaught Error: Class 'config_file_catalog' not found in /xx/xx/admin/includes/classes/security_checks.php:52
Stack trace:
#0 /xx/xx/admin/includes/classes/security_checks.php(36): security_checks->find_modules('/xx/xx...')
#1 /xx/xx/admin/includes/modules/dashboard/d_security_checks.php(30): secur
Please Help
I get below error on the and product edit page does not load properly-
PHP Fatal error: Uncaught TypeError: Argument 3 passed to Select::__construct() must be of the type array, null given, called in /xx/xx/includes/hooks/admin/catalog/soft_redirect.php on line 37 and defined in /xx/xx/includes/system/versioned/1.0.8.1/select.php:32
Stack trace:
#0 /xx/xx/includes/hooks/admin/catalog/soft_redirect.php(37): Select-
20220214T072347: xx/xx/admin/index.php
PHP Fatal error: Uncaught Error: Class 'config_file_catalog' not found in /xx/xx/admin/includes/classes/security_checks.php:52
Stack trace:
#0 /xx/xx/admin/includes/classes/security_checks.php(36): security_checks->find_modules('/xx/xx...')
#1 /xx/xx/admin/includes/modules/dashboard/d_security_checks.php(30): secur
Please Help
-
ecartz
- Core Team
- Posts: 3084
- Joined: Tue Nov 05, 2019 6:02 pm
- Phoenix Version:
- Has thanked: 4 times
- Been thanked: 208 times
Re: s10e06 - Soft Redirect (Products)
Line 37 should beradhavallabh wrote: ↑Mon Feb 14, 2022 12:26 pm PHP Fatal error: Uncaught TypeError: Argument 3 passed to Select::__construct() must be of the type array, null given, called in /xx/xx/includes/hooks/admin/catalog/soft_redirect.php on line 37 and defined in /xx/xx/includes/system/versioned/1.0.8.1/select.php:32
Stack trace:
#0 /xx/xx/includes/hooks/admin/catalog/soft_redirect.php(37): Select-
20220214T072347: xx/xx/admin/index.php
Code: Select all
$redirect_input = (new Select('redirect_id', $products_array, ['autocomplete' => 'off', 'class' => 'form-control w-25', 'id' => 'redTitle', 'aria-describedby' => 'redHelp']))->set_selection($redirect);-
radhavallabh
- Senior Contributor
- Posts: 466
- Joined: Tue Oct 27, 2020 4:09 am
- Phoenix Version: 1.1.0.6
- Has thanked: 29 times
- Been thanked: 3 times
Re: s10e06 - Soft Redirect (Products)
Worked perfectly dear!ecartz wrote: ↑Mon Feb 14, 2022 12:53 pmLine 37 should beradhavallabh wrote: ↑Mon Feb 14, 2022 12:26 pm PHP Fatal error: Uncaught TypeError: Argument 3 passed to Select::__construct() must be of the type array, null given, called in /xx/xx/includes/hooks/admin/catalog/soft_redirect.php on line 37 and defined in /xx/xx/includes/system/versioned/1.0.8.1/select.php:32
Stack trace:
#0 /xx/xx/includes/hooks/admin/catalog/soft_redirect.php(37): Select-
20220214T072347: xx/xx/admin/index.phpCode: Select all
$redirect_input = (new Select('redirect_id', $products_array, ['autocomplete' => 'off', 'class' => 'form-control w-25', 'id' => 'redTitle', 'aria-describedby' => 'redHelp']))->set_selection($redirect);
-
14Steve14
- Senior Contributor
- Posts: 921
- Joined: Fri Oct 25, 2019 7:01 pm
- Phoenix Version: v1.0.9.1
- Has thanked: 17 times
- Been thanked: 103 times
Re: s10e06 - Soft Redirect (Products)
@burt
I currently use this mod on my store, but it is causing some confusion with a minority of customers. This may be something to do with the message we have as we use the mod to discontinued and out of stock items. What I would like to do is to add another modified copy of this mod to the site with a different message, which would allow two messages to be shown, one for out of stock, and one for discontinued.
How much of the code needs changing in one version so as not to conflict with the other. I know I have to change things like the class hooks part of the code, but can it still use the same database tables and things like that.
I currently use this mod on my store, but it is causing some confusion with a minority of customers. This may be something to do with the message we have as we use the mod to discontinued and out of stock items. What I would like to do is to add another modified copy of this mod to the site with a different message, which would allow two messages to be shown, one for out of stock, and one for discontinued.
How much of the code needs changing in one version so as not to conflict with the other. I know I have to change things like the class hooks part of the code, but can it still use the same database tables and things like that.
-
ecartz
- Core Team
- Posts: 3084
- Joined: Tue Nov 05, 2019 6:02 pm
- Phoenix Version:
- Has thanked: 4 times
- Been thanked: 208 times
Re: s10e06 - Soft Redirect (Products)
The only SQL is I don't know that it would be a good idea to reuse that without other changes. Consider modifying the hook to say for the out of stock message. Then you just need to add the out of stock message.
Logic: if there is a redirect set, message that it is discontinued. If not and out of stock, message out of stock. Then there is no need for a "redirect" on the out of stock.
I'm assuming that most of your discontinued items are going to be out of stock as well.
If you wanted to redirect out-of-stock items, I think that you would either need a Boolean to say if something is discontinued or you would need a different "redirect" column. Either way, that would need more SQL. The only way to avoid SQL would be to swap the order of the if statements and always give discontinued items a stock quantity. Something likeThat's a weird use of stock quantity, but I think that it would have the effect that you want. However, I still think that more SQL would be more robust.
Redirecting on out-of-stock can be more complicated than discontinued. Because you may also need to check the stock of the product to which you are redirecting.
Code: Select all
ALTER TABLE products ADD products_redirect INT NULL AFTER products_gtin;Code: Select all
if ($product->get('redirect') > 0) {
$redirect = product_by_id::build((int)$product->get('redirect'));
$GLOBALS['messageStack']->add('product_action', sprintf(RED_SHOPSIDE_ALERT, $redirect->get('name'), $GLOBALS['Linker']->build('product_info.php', ['products_id' => $redirect->get('id')]), 'error'));
} elseif ($product->get('in-stock') <= 0) {
$GLOBALS['messageStack']->add('product_action', sprintf(RED_SHOPSIDE_ALERT_OUT_OF_STOCK, $product->get('name'));
}Logic: if there is a redirect set, message that it is discontinued. If not and out of stock, message out of stock. Then there is no need for a "redirect" on the out of stock.
I'm assuming that most of your discontinued items are going to be out of stock as well.
If you wanted to redirect out-of-stock items, I think that you would either need a Boolean to say if something is discontinued or you would need a different "redirect" column. Either way, that would need more SQL. The only way to avoid SQL would be to swap the order of the if statements and always give discontinued items a stock quantity. Something like
Code: Select all
if ($product->get('redirect') > 0) {
$redirect = product_by_id::build((int)$product->get('redirect'));
if ($product->get('in-stock') <= 0) {
$GLOBALS['messageStack']->add('product_action', sprintf(RED_SHOPSIDE_ALERT_TEMPORARY, $redirect->get('name'), $GLOBALS['Linker']->build('product_info.php', ['products_id' => $redirect->get('id')]), 'error');
} else {
$GLOBALS['messageStack']->add('product_action', sprintf(RED_SHOPSIDE_ALERT, $redirect->get('name'), $GLOBALS['Linker']->build('product_info.php', ['products_id' => $redirect->get('id')]), 'error'));
}
}Redirecting on out-of-stock can be more complicated than discontinued. Because you may also need to check the stock of the product to which you are redirecting.
-
14Steve14
- Senior Contributor
- Posts: 921
- Joined: Fri Oct 25, 2019 7:01 pm
- Phoenix Version: v1.0.9.1
- Has thanked: 17 times
- Been thanked: 103 times
Re: s10e06 - Soft Redirect (Products)
Thanks @ecartz
Just to explain further.
We have out of stock items that are just waiting for new stock to arrive. For SEO we want to keep the product on the website so once we order replacement stock we set the product back to active, and using another addon don't allow the buy button to work as it shows out of stock instead. We like to redirect customers to another product just in case they do buy something rather than go away disappointed. We want to use an out of stock message explaining that the items will be back in stock soon.
We also have some products that we class as discontinued, This means that we are never getting new stock o0f the exact products, but may bought a replacement similar item that we can redirect to again for SEO and still having them listed in Google search. Again once new products are purchased we make the old product active with the buy button inactive. On these we want a discontinued message that explains why the redirect to a different product.
Its difficult to have one message that explains the two different redirects and their reasoning.
I will have a further look at this when time allow, possibly this weekend. It may be one of those things that need the help of a developer.
Just to explain further.
We have out of stock items that are just waiting for new stock to arrive. For SEO we want to keep the product on the website so once we order replacement stock we set the product back to active, and using another addon don't allow the buy button to work as it shows out of stock instead. We like to redirect customers to another product just in case they do buy something rather than go away disappointed. We want to use an out of stock message explaining that the items will be back in stock soon.
We also have some products that we class as discontinued, This means that we are never getting new stock o0f the exact products, but may bought a replacement similar item that we can redirect to again for SEO and still having them listed in Google search. Again once new products are purchased we make the old product active with the buy button inactive. On these we want a discontinued message that explains why the redirect to a different product.
Its difficult to have one message that explains the two different redirects and their reasoning.
I will have a further look at this when time allow, possibly this weekend. It may be one of those things that need the help of a developer.
- Cary
- Member
- Posts: 34
- Joined: Fri Mar 12, 2021 9:36 pm
- Phoenix Version: v1.0.9.1
- Has thanked: 3 times
- Been thanked: 3 times
Re: s10e06 - Soft Redirect (Products)
I'm looking to filter the query a little more as the product info loads slowly sometimes since we have +30k products. Plus, the dropdown wouldn't have as many items listed and would become easier to search in the pulldown. Thoughts on how to limit the query during the product edit to only items in the same category?
I'm hoping that I can edit admin/hooks/includes/soft_redirect.php in a way to limit only showing the products in the same/existing category in this portion with the addition of product_categories filter in the products_query.
I'm hoping that I can edit admin/hooks/includes/soft_redirect.php in a way to limit only showing the products in the same/existing category in this portion with the addition of product_categories filter in the products_query.
Code: Select all
$products_array = [['id' => '', 'text' => RED_DROPDOWN_SELECT]];
$products_query = $GLOBALS['db']->query("SELECT p.products_id, pd.products_name FROM products p, products_description pd WHERE p.products_id = pd.products_id AND p.products_status = 1 AND pd.language_id = " . (int)$_SESSION['languages_id'] . " AND p.products_id != " . $pid . " ORDER BY products_name");
while ($products = $products_query->fetch_assoc()) {
$products_array[$products['products_id']] = ['id' => $products['products_id'], 'text' => $products['products_name'] . ' (pID: ' . $products['products_id'] . ')'];- Cary
-
ecartz
- Core Team
- Posts: 3084
- Joined: Tue Nov 05, 2019 6:02 pm
- Phoenix Version:
- Has thanked: 4 times
- Been thanked: 208 times
Re: s10e06 - Soft Redirect (Products)
Code: Select all
$products_query = $GLOBALS['db']->query(sprintf(<<<'EOSQL'
SELECT p.products_id, pd.products_name
FROM products p
INNER JOIN products_description pd ON p.products_id = pd.products_id
INNER JOIN products_to_categories p2c ON p.products_id = p2c.products_id
WHERE p.products_status = 1 AND pd.language_id = %d AND p.products_id != %d AND p2.categories_id = %d
ORDER BY products_name
EOSQL
, (int)$_SESSION['languages_id'], (int)$pid, (int)$GLOBALS['current_category_id ']))-
lecarlb
- Contributor
- Posts: 316
- Joined: Mon Oct 26, 2020 5:26 pm
- Phoenix Version:
- Has thanked: 48 times
- Been thanked: 9 times
Re: s10e06 - Soft Redirect (Products)
I don't know how this would pan out logically from a coder's view but from a layman's point of view (me), it seems simpler to:
1. Whether product is discontinued or out of stock, show a message then post links to products of the same category or manufacturer after search OR
2. Whether product is discontinued or out of stock, take the visitor directly to a product listing of the same category or manufacturer with a message "this product is out of stock or discontinued, for more info contact us." Of course, the message would be dismissible. OR
3. Keep the addon as is and expand it with either #1 or #2. If that works logically.
That, in my opinion, would further relieve the shop owner of the tedious task of manually linking discontinued products to active products in admin. In the case that the shop owner and staff is very busy or the store is very busy and have lots of products to become discontinued or out of stock simultaneously.
This addon seems to be great as is but I try to challenge myself to think outside of the box. Maybe this will give someone an idea. Also, it would keep the out of stock product live for SEO purposes. And this imagined version shouldn't be a free addon.
1. Whether product is discontinued or out of stock, show a message then post links to products of the same category or manufacturer after search OR
2. Whether product is discontinued or out of stock, take the visitor directly to a product listing of the same category or manufacturer with a message "this product is out of stock or discontinued, for more info contact us." Of course, the message would be dismissible. OR
3. Keep the addon as is and expand it with either #1 or #2. If that works logically.
That, in my opinion, would further relieve the shop owner of the tedious task of manually linking discontinued products to active products in admin. In the case that the shop owner and staff is very busy or the store is very busy and have lots of products to become discontinued or out of stock simultaneously.
This addon seems to be great as is but I try to challenge myself to think outside of the box. Maybe this will give someone an idea. Also, it would keep the out of stock product live for SEO purposes. And this imagined version shouldn't be a free addon.