Prestashop Remove id categories - prestashop

I am Prestashop user im trying to find a url category solution
I need to know the process to remove the category id (Numeric) for Prestashop url.
For Example www.mydomain.com/16-myproducts
Regards

Actually you might do an Override of Dispatcher.php class. It pretty much depends on which version you are.
Here is how we did this at Malttt on 1.6, last year, please take care with this code, as it may be outdated, it also covers other cases (products, suppliers ...) :
/*
* #author Matt Loye <matthieu#agence-malttt.fr>
* #copyright 2016-2017 Agence Malttt
*/
class Dispatcher extends DispatcherCore
{
/**
* #var array List of default routes
*/
public $default_routes = array(
'supplier_rule' => array(
'controller' => 'supplier',
'rule' => 'supplier/{rewrite}/',
'keywords' => array(
'id' => array('regexp' => '[0-9]+'),
'rewrite' => array('regexp' => '[_a-zA-Z0-9-\pL]*', 'param' => 'supplier_rewrite'),
'meta_keywords' => array('regexp' => '[_a-zA-Z0-9-\pL]*'),
'meta_title' => array('regexp' => '[_a-zA-Z0-9-\pL]*'),
),
),
'manufacturer_rule' => array(
'controller' => 'manufacturer',
'rule' => 'manufacturer/{rewrite}/',
'keywords' => array(
'id' => array('regexp' => '[0-9]+'),
'rewrite' => array('regexp' => '[_a-zA-Z0-9-\pL]*', 'param' => 'manufacturer_rewrite'),
'meta_keywords' => array('regexp' => '[_a-zA-Z0-9-\pL]*'),
'meta_title' => array('regexp' => '[_a-zA-Z0-9-\pL]*'),
),
),
'cms_rule' => array(
'controller' => 'cms',
'rule' => 'info/{rewrite}',
'keywords' => array(
'id' => array('regexp' => '[0-9]+'),
'rewrite' => array('regexp' => '[_a-zA-Z0-9-\pL]*', 'param' => 'cms_rewrite'),
'meta_keywords' => array('regexp' => '[_a-zA-Z0-9-\pL]*'),
'meta_title' => array('regexp' => '[_a-zA-Z0-9-\pL]*'),
),
),
'cms_category_rule' => array(
'controller' => 'cms',
'rule' => 'info/{rewrite}/',
'keywords' => array(
'id' => array('regexp' => '[0-9]+'),
'rewrite' => array('regexp' => '[_a-zA-Z0-9-\pL]*', 'param' => 'cms_category_rewrite'),
'meta_keywords' => array('regexp' => '[_a-zA-Z0-9-\pL]*'),
'meta_title' => array('regexp' => '[_a-zA-Z0-9-\pL]*'),
),
),
'module' => array(
'controller' => null,
'rule' => 'module/{module}{/:controller}',
'keywords' => array(
'module' => array('regexp' => '[_a-zA-Z0-9_-]+', 'param' => 'module'),
'controller' => array('regexp' => '[_a-zA-Z0-9_-]+', 'param' => 'controller'),
),
'params' => array(
'fc' => 'module',
),
),
'product_rule' => array(
'controller' => 'product',
'rule' => '{category:/}{rewrite}.html',
'keywords' => array(
'id' => array('regexp' => '[0-9]+'),
'rewrite' => array('regexp' => '[_a-zA-Z0-9-\pL]*', 'param' => 'product_rewrite'),
'ean13' => array('regexp' => '[0-9\pL]*'),
'category' => array('regexp' => '[_a-zA-Z0-9-\pL]*'),
'categories' => array('regexp' => '[/_a-zA-Z0-9-\pL]*'),
'reference' => array('regexp' => '[_a-zA-Z0-9-\pL]*'),
'meta_keywords' => array('regexp' => '[_a-zA-Z0-9-\pL]*'),
'meta_title' => array('regexp' => '[_a-zA-Z0-9-\pL]*'),
'manufacturer' => array('regexp' => '[_a-zA-Z0-9-\pL]*'),
'supplier' => array('regexp' => '[_a-zA-Z0-9-\pL]*'),
'price' => array('regexp' => '[0-9\.,]*'),
'tags' => array('regexp' => '[a-zA-Z0-9-\pL]*'),
),
),
'layered_rule' => array(
'controller' => 'category',
'rule' => '{rewrite}/filter{selected_filters}',
'keywords' => array(
'id' => array('regexp' => '[0-9]+'),
/* Selected filters is used by the module blocklayered */
'selected_filters' => array('regexp' => '.*', 'param' => 'selected_filters'),
'rewrite' => array('regexp' => '[_a-zA-Z0-9-\pL]*', 'param' => 'category_rewrite'),
'meta_keywords' => array('regexp' => '[_a-zA-Z0-9-\pL]*'),
'meta_title' => array('regexp' => '[_a-zA-Z0-9-\pL]*'),
),
),
'category_rule' => array(
'controller' => 'category',
'rule' => '{rewrite}/',
'keywords' => array(
'id' => array('regexp' => '[0-9]+'),
'categories' => array('regexp' => '[/_a-zA-Z0-9-\pL]*'),
'rewrite' => array('regexp' => '[_a-zA-Z0-9-\pL]*', 'param' => 'category_rewrite'),
'meta_keywords' => array('regexp' => '[_a-zA-Z0-9-\pL]*'),
'meta_title' => array('regexp' => '[_a-zA-Z0-9-\pL]*'),
),
),
);
}

Related

How can I add a cipher_suite to the Erlang default ones?

I'm currently trying to add the cipher TLS_PSK_WITH_AES_128_CBC_SHA_256 to my default cipher_suite in Erlang 24 (on a CentOS 8 machine). Unfortunately, I'm not sure how to do so.
I know that the cipher is their cause:
1> ssl:str_to_suite("TLS_PSK_WITH_AES_128_CBC_SHA_256").
returns:
#{cipher => aes_128_cbc,key_exchange => psk,mac => sha256,
prf => sha256}
I do also know that the cipher is not activate cause
rp(ssl:cipher_suites(default,'tlsv1.2')).
does not list it:
[#{cipher => aes_256_gcm,key_exchange => ecdhe_ecdsa,
mac => aead,prf => sha384},
#{cipher => aes_256_gcm,key_exchange => ecdhe_rsa,mac => aead,
prf => sha384},
#{cipher => aes_256_ccm,key_exchange => ecdhe_ecdsa,
mac => aead,prf => default_prf},
#{cipher => aes_256_ccm_8,key_exchange => ecdhe_ecdsa,
mac => aead,prf => default_prf},
#{cipher => aes_256_cbc,key_exchange => ecdhe_ecdsa,
mac => sha384,prf => sha384},
#{cipher => aes_256_cbc,key_exchange => ecdhe_rsa,
mac => sha384,prf => sha384},
#{cipher => chacha20_poly1305,key_exchange => ecdhe_ecdsa,
mac => aead,prf => sha256},
#{cipher => chacha20_poly1305,key_exchange => ecdhe_rsa,
mac => aead,prf => sha256},
#{cipher => aes_128_gcm,key_exchange => ecdhe_ecdsa,
mac => aead,prf => sha256},
#{cipher => aes_128_gcm,key_exchange => ecdhe_rsa,mac => aead,
prf => sha256},
#{cipher => aes_128_ccm,key_exchange => ecdhe_ecdsa,
mac => aead,prf => default_prf},
#{cipher => aes_128_ccm_8,key_exchange => ecdhe_ecdsa,
mac => aead,prf => default_prf},
#{cipher => aes_256_gcm,key_exchange => ecdh_ecdsa,
mac => aead,prf => sha384},
#{cipher => aes_256_gcm,key_exchange => ecdh_rsa,mac => aead,
prf => sha384},
#{cipher => aes_256_cbc,key_exchange => ecdh_ecdsa,
mac => sha384,prf => sha384},
#{cipher => aes_256_cbc,key_exchange => ecdh_rsa,
mac => sha384,prf => sha384},
#{cipher => aes_128_gcm,key_exchange => ecdh_ecdsa,
mac => aead,prf => sha256},
#{cipher => aes_128_gcm,key_exchange => ecdh_rsa,mac => aead,
prf => sha256},
#{cipher => aes_128_cbc,key_exchange => ecdhe_ecdsa,
mac => sha256,prf => sha256},
#{cipher => aes_128_cbc,key_exchange => ecdhe_rsa,
mac => sha256,prf => sha256},
#{cipher => aes_128_cbc,key_exchange => ecdh_ecdsa,
mac => sha256,prf => sha256},
#{cipher => aes_128_cbc,key_exchange => ecdh_rsa,
mac => sha256,prf => sha256},
#{cipher => aes_256_gcm,key_exchange => dhe_rsa,mac => aead,
prf => sha384},
#{cipher => aes_256_gcm,key_exchange => dhe_dss,mac => aead,
prf => sha384},
#{cipher => aes_256_cbc,key_exchange => dhe_rsa,mac => sha256,
prf => default_prf},
#{cipher => aes_256_cbc,key_exchange => dhe_dss,mac => sha256,
prf => default_prf},
#{cipher => aes_128_gcm,key_exchange => dhe_rsa,mac => aead,
prf => sha256},
#{cipher => aes_128_gcm,key_exchange => dhe_dss,mac => aead,
prf => sha256},
#{cipher => chacha20_poly1305,key_exchange => dhe_rsa,
mac => aead,prf => sha256},
#{cipher => aes_128_cbc,key_exchange => dhe_rsa,mac => sha256,
prf => default_prf},
#{cipher => aes_128_cbc,key_exchange => dhe_dss,mac => sha256,
prf => default_prf},
#{cipher => aes_256_cbc,key_exchange => ecdhe_ecdsa,
mac => sha,prf => default_prf},
#{cipher => aes_256_cbc,key_exchange => ecdhe_rsa,mac => sha,
prf => default_prf},
#{cipher => aes_256_cbc,key_exchange => ecdh_ecdsa,mac => sha,
prf => default_prf},
#{cipher => aes_256_cbc,key_exchange => ecdh_rsa,mac => sha,
prf => default_prf},
#{cipher => aes_128_cbc,key_exchange => ecdhe_ecdsa,
mac => sha,prf => default_prf},
#{cipher => aes_128_cbc,key_exchange => ecdhe_rsa,mac => sha,
prf => default_prf},
#{cipher => aes_128_cbc,key_exchange => ecdh_ecdsa,mac => sha,
prf => default_prf},
#{cipher => aes_128_cbc,key_exchange => ecdh_rsa,mac => sha,
prf => default_prf},
#{cipher => aes_256_cbc,key_exchange => dhe_rsa,mac => sha,
prf => default_prf},
#{cipher => aes_256_cbc,key_exchange => dhe_dss,mac => sha,
prf => default_prf},
#{cipher => aes_128_cbc,key_exchange => dhe_rsa,mac => sha,
prf => default_prf},
#{cipher => aes_128_cbc,key_exchange => dhe_dss,mac => sha,
prf => default_prf}]
I need this cipher cause I want to connect to RabbitMQ (with the MQTT Plugin) for a device.
Does anyone know how to activate/enable a cipher in Erlang ?

TypeError: undefined is not an object (evaluating 'items.filter') in react native

Why I am getting that error TypeError: undefined is not an object (evaluating 'items.filter') when using react-native-dropdown-autocomplete in my react native app?
I am getting data from fetch method and store that data in arrayholder
My code is like that
<Autocomplete
style={styles.input}
scrollToInput={ev => {}}
keyExtractor={(item, index) => index + ""}
handleSelectItem={(item, id) => this.handleSelectItem(item, id)}
onDropdownClose={() => onDropdownClose()}
onDropdownShow={() => onDropdownShow()}
onChangeText={(text) => this.searchFilterFunction(text)}
data={this.state.data}
minimumCharactersCount={0}
highlightText
valueExtractor={item => item.name}
rightContent
/>
searchFilterFunction = (text) => {
this.setState({
value: text,
});
const newData = this.arrayholder.filter(item => {
const itemData = `${item.name.toUpperCase()}`;
const textData = text.toUpperCase();
return itemData.indexOf(textData) > -1;
});
this.setState({ data: newData });
};

Trying to get result from more than one api React native in the same page

i m trying to get data from database and put it inside a picker when i use one fecth it work fine but when i add the second one it get an error says " typeError: undefined is not an object (evaluating 'this.state.dataSource2.map') "
componentDidMount() {
fetch('url1')
.then((response) => response.json())
.then((responseJson) => {
this.setState({
isLoading: false,
dataSource: responseJson,
}
);
})
.then( () => {
fetch('url2')
.then((response) => response.json())
.then((responseJson) => {
this.setState({
isLoading: false,
dataSource2: responseJson
});
})
})
.catch((error) => {
console.error(error);
});
}
first picker :
onValueChange={(itemValue, itemIndex) => this.setState({ar1: itemValue})} >
{ this.state.dataSource.map((item, key)=>(
<Picker.Item label={item.nom} value={item.nom} key={key} />)
)}
</Picker>
second picker :
onValueChange={(itemValue, itemIndex) => this.setState({ar2: itemValue})} >
{ this.state.dataSource2.map((item, key)=>(
<Picker.Item label={item.nom} value={item.nom} key={key} />)
)}
</Picker>

How to display fetched data in react native

I successfully posted data in MongoDB Atlas, Now i want to display that data in my simple react native App. Data is showing in my terminal but i am not able to display data in my App.
Here is code for Get data form the db.
display(){
fetch('myUrl', {
method: 'GET'
})
.then((response) => response.json())
.then((responseJson) => {
console.log(responseJson);
this.setState({
title: responseJson,
description: responseJson
})
})
.catch((error) => {
console.error(error);
});
}
Here is the code that is not displaying the data in App
<TouchableOpacity onPress={()=>this.display()} style={styles.btn}>
<Text style={{textAlign: 'center'}}> Display </Text>
</TouchableOpacity>
<View>
<FlatList
data={this.state.title}
renderItem={({item}) => <Text>{item.title}</Text>}
keyExtractor={({id}, index) => id}
/>
</View>
Flatlist data property expects an array.
But you seem to set an object.
If your api returns an array you can make the following changes to make it work:
state = {
items:[]
}
display() {
fetch('myUrl', { method: 'GET'})
.then((response) => response.json())
.then((responseJson) => {
console.log(responseJson);
this.setState({
items: responseJson
})
})
.catch((error) => {
console.error(error);
});
}
As you see I used items in state as array, and updated its value when I got response from api.
And in flatlist:
<View>
<FlatList
data={this.state.items}
renderItem={({item}) => <Text key={item._id}>{item.title}</Text>}
keyExtractor={ item => item._id}
/>
</View>
A sample codesandbox
Update your code like this:
this.state = {
responseData:[]
}
display = () => {
fetch('myUrl', {
method: 'GET'
})
.then((response) => response.json())
.then((responseJson) => {
console.log(responseJson);
this.setState({
responseData: responseJson,
})
})
.catch((error) => {
console.error(error);
});
}
inside your render function:
render(){
const { responseData } = this.state;
return(
<TouchableOpacity onPress={()=>this.display} style={styles.btn}>
<Text style={{textAlign: 'center'}}> Display </Text>
</TouchableOpacity>
<View>
<FlatList
data={responseData}
renderItem={this.renderItem}
keyExtractor={item => item.id}
/>
</View>
);
}
renderItem = ({item}) => {
const { title, id, description, date } = item;
<View key={item.id}>
<Text>{item.id}</Text>
<Text>{item.title}</Text>
<Text>{item.description}</Text>
<Text>{item.date}</Text>
</View>
}
try with return keywork
Working demo api
display(){
return fetch('myUrl', {
method: 'GET'
})
.then((response) => response.json())
.then((responseJson) => {
console.log(responseJson);
this.setState({
title: responseJson,
description: responseJson
})
})
.catch((error) => {
console.error(error);
});
}

Algolia instantsearch pagination not working

refine() is not working in react-native
const InfiniteHits = ({ hits, hasMore, refine }) => {
return <FlatList
data={hits}
keyExtractor={item => item.objectID}
onEndReached={() => refine()}
renderItem={({ item }) => (
<CardListingItem item={item}/>
)}
/>
}
I tried another alternative using connectPagination also not working:
const Pagination = ({refine}) => {
return <Button
title="more"
onPress={() => refine()}
/>
}
export const ConnectedPagination = connectPagination(Pagination)
Version:
"algoliasearch": "^3.33.0",
"react-instantsearch-native": "^5.6.0",
what's the problem ?