| 1 |
<?php |
| 2 |
/** |
| 3 |
* DB Model Utility |
| 4 |
* |
| 5 |
* @package Disco |
| 6 |
* @subpackage App\Utility |
| 7 |
* @since 1.0.0 |
| 8 |
* @category Utility |
| 9 |
*/ |
| 10 |
|
| 11 |
namespace Disco\App\Utility; |
| 12 |
|
| 13 |
/** |
| 14 |
* Class Model |
| 15 |
* |
| 16 |
* @package Disco |
| 17 |
* @subpackage App\Utility |
| 18 |
* @author Ohidul Islam <wahid0003@gmail.com> |
| 19 |
* @link https://webappick.com |
| 20 |
* @license https://opensource.org/licenses/gpl-license.php GNU Public License |
| 21 |
* @category Utility |
| 22 |
*/ |
| 23 |
class Model { |
| 24 |
|
| 25 |
/** |
| 26 |
* Get all product attributes. |
| 27 |
* |
| 28 |
* @param string $like Search Term. |
| 29 |
* @return array |
| 30 |
*/ |
| 31 |
public function wc_global_attribute_query( $like = '' ) { |
| 32 |
global $wpdb; |
| 33 |
$query = $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}woocommerce_attribute_taxonomies WHERE attribute_name != '' AND attribute_name LIKE %s", $like . '%' ); |
| 34 |
|
| 35 |
return $wpdb->get_results( $query ); //phpcs:ignore |
| 36 |
} |
| 37 |
|
| 38 |
/** |
| 39 |
* Get all product custom attributes. |
| 40 |
* |
| 41 |
* @param string $like Search Term. |
| 42 |
* @return array |
| 43 |
*/ |
| 44 |
public function wc_custom_attribute_query( $like = '' ) { |
| 45 |
global $wpdb; |
| 46 |
$query = $wpdb->prepare( 'SELECT meta.meta_id, meta.meta_key as name, meta.meta_value as type FROM ' . $wpdb->postmeta . ' AS meta, ' . $wpdb->posts . " AS posts WHERE meta.post_id = posts.id AND posts.post_type LIKE %s AND meta.meta_key='_product_attributes'", $like . '%' ); |
| 47 |
|
| 48 |
return $wpdb->get_results( $query ); //phpcs:ignore |
| 49 |
} |
| 50 |
|
| 51 |
} |
| 52 |
|