Seo url doens't work with homepage in OpenCart 3 - seo

I've enabled the option (Use SEO URLs) in settings (Opencart 3). All links such as contact, about, etc are working, except the homepage!
I have added this to the SEO URL page:
Query: common/home
Keyword: home
But it still appears as: index.php?route=common/home
How can I fix that?

I hope it will help you as
Please make changes in catalog/controller/startup/seo_url.php
if `(($data['route'] == 'product/product' && $key == 'product_id') ||
(($data['route'] == 'product/manufacturer/info' ||
$data['route'] == 'product/product') && $key == 'manufacturer_id') ||
($data['route'] == 'information/information' && $key == 'information_id'))
{
to
if (($data['route'] == 'product/product' && $key == 'product_id') ||
(($data['route'] == 'product/manufacturer/info' ||
$data['route'] == 'product/product') && $key == 'manufacturer_id') ||
($data['route'] == 'information/information' && $key == 'information_id') ||
$data['route'] == 'common/home')
{

The problem is the link on the main logo. You can fix this issue by installing the vQmod that is free to download at this link:
https://www.antropy.co.uk/blog/one-quick-opencart-seo-tip-to-avoid-a-duplicate-home-page/

Related

How to apply a filter on many columns by `awk`

I want to apply a filter to every 5th column in a file by using awk and print the entire line if all conditions are met on the specified columns. How can I shorten this code?
awk -F "\t" '{if ($5>=10 && $10>=10 && $15>=10 && $20>=10 && $25>=10 && $30>=10 && $35>=10 && $40>=10 && $45>=10 && $50>=10 && $55>=10 && $60>=10 && $65>=10 && $70>=10 && $75>=10 && $80>=10 && $85>=10 && $90>=10 && $95>=10 && $100>=10 && $105>=10 && $110>=10 && $115>=10 && $120>=10 && $125>=10 && $130>=10 && $135>=10 && $140>=10 && $145>=10 && $150>=10 && $155>=10 && $160>=10 && $165>=10 && $170>=10 && $175>=10 && $180>=10 && $185>=10 && $190>=10 && $195>=10 && $200>=10 && $205>=10 && $210>=10 && $215>=10 && $220>=10 && $225>=10 && $230>=10 && $235>=10 && $240>=10 && $245>=10 && $250>=10 && $255>=10 && $260>=10 && $265>=10 && $270>=10 && $275>=10 && $280>=10 && $285>=10 && $290>=10 && $295>=10 && $300>=10 && $305>=10 && $310>=10 && $315>=10 && $320>=10 && $325>=10 && $330>=10 && $335>=10 && $340>=10 && $345>=10 && $350>=10 && $355>=10 && $360>=10 && $365>=10 && $370>=10 && $375>=10 && $380>=10 && $385>=10 && $390>=10) print}' file
You can use a for loop to iterate a column index with a step of 5, and skip to the next record if any of the columns at such indices is less than 10:
awk -F "\t" '{for(i=5;i<=NF;i+=5)if($i<10)next;print}' file
Looping and checking every 5th field as in the other answers is the correct approach but the conditional requires all instances to pass the condition to be satisfied.
Therefore, within the loop, keep track of satisfied conditions with a variable (in my example fail). The first condition failure sets the variable to indicate failure and breaks from the loop. The print statement is executed only if none of the conditions failed:
awk '{for(i=5;i<=NF;i+=5)if($i<10){fail="fail";break;} if (fail != "fail") print }' file.txt
Untested as I'm not clear as to what you want to print, the line or just each fifth element (and that's not part of the question). Also I left out the field-separator reset as I don't think it is needed.
You can iterate all fields
awk '{a=1; for (i =1 ; i<= NF ; ++i) if ( i%5==0 ) a=a&&$i>10; if (a) print file
Edit: All 5th fields greater than 10

awk compare adjacent lines and print based on if statements

I have one file with multiple lines (reads from a genome) and they are sorted (based on their locations). Now I want to loop over these lines and if multiple lines have the same ID (column 4), I want to keep either keep the first, if column 3 is a plus or the last, if column three is a minus. This is m code but it seems like my variable (lastID) is not properly updated after each line.
Tips are much appreciated.
awk 'BEGIN {lastline=""; lastID=""}
{if ($lastline != "" && $4 != $lastID)
{print $lastline; lastline=""};
if ($3 == "+" && $4 != $lastID)
{print $0; lastline=""}
else if ($3 == "+" && $4 == $lastID)
{lastli=""}
else if ($3 == "-")
{lastline=$0};
lastID=$4
}' file
To access the value of a variable in awk you just use the name of the variable, just like in C and most other Algol-based languages. You don't stick a $ in front of it like you would with shell. Try changing:
$lastline != "" && $4 != $lastID
to:
lastline != "" && $4 != lastID
etc.
This might be what you're trying to do (your BEGIN section was doing nothing useful so I just removed it):
awk '
(lastline != "") && ($4 != lastID) {
print lastline
lastline=""
}
$3 == "+" {
if ($4 == lastID) {
lastli=""
}
else {
print $0
lastline=""
}
}
$3 == "-" {
lastline=$0
}
{ lastID=$4 }
' file
When formatted sensibly like that you can see that lastli is never used anywhere except where it's set to "" so that's probably a bug - maybe it's supposed to lastline in which case it can be made common rather than being set in both the if and else legs?
you may want to utilize awk's own condition{statement} structure. Note that code layout is not universally accepted but I find it easier to read for short statements.
$ awk '$lastline!="" && $4 != $lastID {print lastline; lastline=""}
$3=="+" && $4 != $lastID {print; lastline=""}
$3=="+" && $4 == $lastID {lastli=""}
$3=="-" {lastline=$0}
{lastID=$4}' file

Smarty OR statement

This is working:
{if $filter.id_key='68'}
This doesn't:
{if ($filter.id_key='68' || $filter.id_key='63')}
Not sure what's wrong here (tried also without the round brackets). There are plenty of examples of the same OR statement in the same file.
In {if $filter.id_key='68'} you are assigning 68 to $filter.id_key, so it's always true. You should use double equal ==:
{if ($filter.id_key == '68' || $filter.id_key == '63')}

awk statement to get output in one line

Please suggest -
Input File -
G238740
G316342
G748951
G952443
G955221
G952842
G767727
G339717
G712953
Command i tried:
awk -F";" '{ print "displayName == \""$1"\" " "||" }' input
Current output -
displayName == "G238740" ||
displayName == "G316342" ||
displayName == "G748951" ||
displayName == "G952443" ||
displayName == "G955221" ||
displayName == "G952842" ||
displayName == "G767727" ||
displayName == "G339717" ||
displayName == "G712953" ||
Desired output , How to get output in one single line
displayName == "G238740" || displayName == "G316342" || displayName == "G748951"
Use printf instead of print, so it won't add a newline. And then conditionally print the || separator on all lines but the first:
awk '{printf("%sdisplayName == \"%s\"", (NR == 1 ? "" : " || "), $1)}
END {print ""}' input

Awk: Print to different files using multiple defined variables

I am opening up a file and checking if the items in columns 1 & 8 match certain specs. If yes, write output to a file x. If the items in column 1 match specs but column 8 does not match the specs, write output to file y.
I am defining multiple variables (awk -v v=$var,f1=$file,f2=$output), and I believe how I reference f1 & f2 is the problem. If I remove the quotes:
print $0 >> f2
awk: cmd. line:5: (FILENAME=- FNR=2) fatal: expression for `>>' redirection has null string value
If I put in a $:
print $0 >> $f2
I end up with a bunch of files with odd names that I don't want, and the files I do want are empty (except for the echoed line).
if I put "":
print $0 >> "f2"
The files I want are almost empty, and it creates a file called f2.
#!/bin/bash
output="output.txt"
echo -e "C1\tSeqID\tAminoAcid\tCD1\tCD2\tCD3\tGene\tEnvironment\tFilename" > $output
inputFile="input.txt.gz"
for var in A B C D E F G H I J K L
do
file=$var".txt"
echo -e "C1\tSeqID\tAA\tCD1\tCD2\tCD3\tGene\tEnvironment\tFilename" > $file
#---Wrong, forgot to catch $8 != v
#zcat $inputFile | awk -v v=$var '{
# if ($8 == v && ($1 == "V1" || $1 == "V2" || $1 == "V3" || $1 == "V4" || $1 == "V5" || $1 == "V6" || $1 == "V7" || $1 == "V8" || $1 == "V9" || $1 == "V10"))
# print $0
# }' | tee -a $file $output
zcat $inputFile | awk -v v=$var,f1=$file,f2=$output '{
if ($8 == v && ($1 == "V1" || $1 == "V2" || $1 == "V3" || $1 == "V4" || $1 == "V5" || $1 == "V6" || $1 == "V7" || $1 == "V8" || $1 == "V9" || $1 == "V10"))
print $0 >> "file"
else if ($8 != v && ($1 == "V1" || $1 == "V2" || $1 == "V3" || $1 == "V4" || $1 == "V5" || $1 == "V6" || $1 == "V7" || $1 == "V8" || $1 == "V9" || $1 == "V10"))
print $0 >> "f2"
}'
gzip $file
done
gzip $output
I can run through the loop and have two separate awk commands that write to different files. However, it is a very large file (4G compressed) and it is more efficient to use my current approach (or something similar to it). Any guidance on how to reference the 2nd & 3rd variable are greatly appreciated.
Use separate -vs:
awk -v v="$var" -v f1="$file" -v f2="$output" '...'
% awk -v v=qw,f1=we,f2=as 'BEGIN{print v, "*", f1, "*", f2}'
qw,f1=we,f2=as * *
% awk -v v=qw -v f1=we -v f2=as 'BEGIN{print v, "*", f1, "*", f2}'
qw * we * as
%
Do you need anything else to proceed?