logo
down
shadow

product search by Category


product search by Category

Content Index :

product search by Category
Tag : php , By : Marcos de Carvalho
Date : November 26 2020, 06:23 AM

fixed the issue. Will look into that further You can use find_in_set(),
select * from products where find_in_set(1,c_id);
select * from products where find_in_set(3,c_id);

Comments
No Comments Right Now !

Boards Message :
You Must Login Or Sign Up to Add Your Comments .

Share : facebook icon twitter icon

Magento Product View Page: Add Layout Changes Depending on Product Search or Category Browsing


Tag : php , By : Skee
Date : March 29 2020, 07:55 AM
With these it helps In order to use custom layout handles in your local.xml file, first you have to make an observer for it. To create an observer, you start out by adding it as an extension / module. Create the following files/folders if not present (The names Yourname and Modulename can be anything, just make sure it's the same where it shows up, including upper/lower case):
Directory View
/app/etc/modules/Yourname_Modulename.xml
/app/code/local/Yourname/Modulename/etc/config.xml
/app/code/local/Yourname/Modulename/Model/Observer.php
<?xml version="1.0"?>
<config>
    <modules>
        <Yourname_Modulename>
            <codePool>local</codePool>
            <active>true</active>
        </Yourname_Modulename>
    <modules>
<config>
<?xml version="1.0"?>
<config>
    <global>
        <models>
            <yournamemodulename>
                <class>Yourname_Modulename_Model</class>
            </yournamemodulename>
        </models>
    </global>
    <frontend>
        <events>
            <controller_action_layout_load_before>
                <observers>
                    <yourname_modulename_model_observer>
                        <type>singleton</type>
                        <class>Yourname_Modulename_Model_Observer</class>
                        <method>controllerActionLayoutLoadBefore</method>
                    </yourname_modulename_model_observer>
                </observers>
            </controller_action_layout_load_before>
        </events>
    </frontend>
</config>
<?php
    class Yourname_Modulename_Model_Observer
    {
        public function controllerActionLayoutLoadBefore( Varien_Event_Observer $observer)
        {
            //Get Layout Object
            $layout = $observer->getEvent()->getLayout();

            /*
            *Begin Logic to Determine If Layout Handle Should Be Applied.
            *Below Determines If We Are On A Product View Page.
            *Here is Where You Would Modify The Code For Different Layout Handles
            */
            if( Mage::registry( 'current_product' ) ) {

                //Check if current_category is set
                if( Mage::registry( 'current_category' ) ) {

                    //Send Layout Update Handle If Product Was Browsed
                    $layout->getUpdate()->addHandle( 'your_layout_handle' );
                }
                else {

                    //Send Layout Update Handle If Product Was Linked or Searched
                    $layout->getUpdate()->addHandle( 'your_other_handle' );
                }
            }
        }
    }
<!-- Jump To Relevant Section -->

    <catalog_product_view_browsed>
        <reference name="left">
            <action method="unsetChild">
                <name>left.poll</name>
            </action>
        </reference>
        <reference name="right">
            <action method="insert">
                <blockName>left.poll</blockName>
                <siblingName>right.newsletter</siblingName>
                <after>0</after>
            </action>
        </reference>
    </catalog_product_view_browsed>

    <catalog_product_view_searched>
        <reference name="left">
            <action method="insert">
                <blockName>right.newsletter</blockName>
                <siblingName>left.vertnav</siblingName>
                <after>1</after>
            </action>
        </reference>
        <reference name="right">
            <action method="unsetChild">
                <name>right.newsletter</name>
            </action>
        </reference>
    </catalog_product_view_browsed>

<!-- End Relevant Section -->

How to get category name in opencart product search result page


Tag : php , By : fedorafennec
Date : March 29 2020, 07:55 AM
may help you . My Controller : , Replace this code
$data['products'][] = array(
                    'product_id'  => $result['product_id'],
                    'thumb'       => $image,
                    'name'        => $result['name'],
                    //'description' => utf8_substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 0, $this->config->get('config_product_description_length')) . '..',
                    'description' => html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8'),
                    'price'       => $price,
                    'special'     => $special,
                    'tax'         => $tax,
                    'minimum'     => $result['minimum'] > 0 ? $result['minimum'] : 1,
                    'rating'      => $result['rating'],
                    'href'        => $this->url->link('product/product', 'product_id=' . $result['product_id'] . $url)
                );
$cats = $this->model_catalog_product->getCategories($product_info['product_id']);

$sep = '';
$catnames = '';

foreach ($cats as $cat){

    $catarr = $this->model_catalog_category->getCategory($cat['category_id']);

    $catnames .= $sep.$catarr['name'];
    $sep = ', ';
}

$data['products'][] = array(
                    'product_id'  => $result['product_id'],
                    'thumb'       => $image,
                    'name'        => $result['name'],
                    //'description' => utf8_substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 0, $this->config->get('config_product_description_length')) . '..',
                    'description' => html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8'),
                    'price'       => $price,
                    'special'     => $special,
                    'tax'         => $tax,
                    'minimum'     => $result['minimum'] > 0 ? $result['minimum'] : 1,
                    'rating'      => $result['rating'],
                    'category'    => $catnames,
                    'href'        => $this->url->link('product/product', 'product_id=' . $result['product_id'] . $url)
                );

Predicting product's category by search term


Tag : machine-learning , By : user157654
Date : March 29 2020, 07:55 AM
wish helps you I think that's the correct way of solving the problem, since you're dealing with a multi-label classification problem. That is, a sample can belong to several classes simultaneously, or to a single class, or to none of the classes (categories).
This is a good example on Python: multi-label classification. You can get more details here.

Replace woocommerce product category thumbnail with image of latest product in respective category


Tag : php , By : cheese_doodle
Date : March 29 2020, 07:55 AM
To fix the issue you can do Add the follows code snippet in your active theme's functions.php to achieve the above -
function modify_woocommerce_before_shop_loop() {
    remove_action( 'woocommerce_before_subcategory_title', 'woocommerce_subcategory_thumbnail', 10 );
    add_action( 'woocommerce_before_subcategory_title', 'change_woocommerce_subcategory_thumbnail', 10 );
}
add_action( 'woocommerce_before_shop_loop', 'modify_woocommerce_before_shop_loop' );

function change_woocommerce_subcategory_thumbnail( $category ) {
    global $wpdb;
    $small_thumbnail_size = apply_filters( 'subcategory_archive_thumbnail_size', 'woocommerce_thumbnail' );
    $dimensions           = wc_get_image_size( $small_thumbnail_size );
    // Get the latest product from the category
    $product = $wpdb->get_row("SELECT 
        ID FROM $wpdb->posts p
        JOIN $wpdb->term_relationships tr ON (p.ID = tr.object_id)
        JOIN $wpdb->term_taxonomy tt ON (tr.term_taxonomy_id = tt.term_taxonomy_id)
        JOIN $wpdb->terms t ON (tt.term_id = t.term_id)
        WHERE p.post_type='product'
        AND p.post_status = 'publish'
        AND tt.taxonomy = 'product_cat'
        AND t.term_id = $category->term_id
        ORDER BY post_date DESC LIMIT 1");
    if( $product ) {
        $thumbnail_id         = get_post_meta( $product->ID, '_thumbnail_id', true );
    }else {
        $thumbnail_id         = get_term_meta( $category->term_id, 'thumbnail_id', true );
    }

    if ( $thumbnail_id ) {
        $image        = wp_get_attachment_image_src( $thumbnail_id, $small_thumbnail_size );
        $image        = $image[0];
        $image_srcset = function_exists( 'wp_get_attachment_image_srcset' ) ? wp_get_attachment_image_srcset( $thumbnail_id, $small_thumbnail_size ) : false;
        $image_sizes  = function_exists( 'wp_get_attachment_image_sizes' ) ? wp_get_attachment_image_sizes( $thumbnail_id, $small_thumbnail_size ) : false;
    } else {
        $image        = wc_placeholder_img_src();
        $image_srcset = false;
        $image_sizes  = false;
    }

    if ( $image ) {
        // Prevent esc_url from breaking spaces in urls for image embeds.
        // Ref: https://core.trac.wordpress.org/ticket/23605.
        $image = str_replace( ' ', '%20', $image );

        // Add responsive image markup if available.
        if ( $image_srcset && $image_sizes ) {
            echo '<img src="' . esc_url( $image ) . '" alt="' . esc_attr( $category->name ) . '" width="' . esc_attr( $dimensions['width'] ) . '" height="' . esc_attr( $dimensions['height'] ) . '" srcset="' . esc_attr( $image_srcset ) . '" sizes="' . esc_attr( $image_sizes ) . '" />';
        } else {
            echo '<img src="' . esc_url( $image ) . '" alt="' . esc_attr( $category->name ) . '" width="' . esc_attr( $dimensions['width'] ) . '" height="' . esc_attr( $dimensions['height'] ) . '" />';
        }
    }
}

Magento - How to filter a product collection using multiple category when flat product/category is on


Tag : magento , By : Chris Hubbard
Date : March 29 2020, 07:55 AM
Related Posts Related QUESTIONS :
  • Assign indexed array values to multidimensional array?
  • Custom WordPress stylesheet not loading
  • Data attribute only returning first value
  • How to list all roles with Permissions,in spatie permission Package?
  • How to achieve this number pattern with n input
  • How to iterate array inside array data in laravel ,output are given below
  • To get output of movie with its genre
  • Extracting some data from a JS object literal string in PHP using Regex
  • axios and vuex are deleting wrong index in array
  • Setting empty CURLOPT_POSTFIELDS
  • Laravel 5.8 use subdomain as API endpoint beside domain.com/api
  • Error while add data in database SQL Server 2016
  • Does PhpStorm allow to skip PHPDoc tags when type hints is declared?
  • html classes are changed to Attributes
  • Using json to import multidimensional data
  • passing data from the view to the controller, where the data comes from another controller
  • How to extract integer and decimal numbers in PHP string correctly?
  • Parsing Sub-Object from an XML Feed with objects
  • Getting error "Unknown column 'text' in 'field list'"
  • How to properly get onedrive access token via php and curl
  • How to add spell check to a php function
  • Is it posible to create css rules with php?
  • Pretty URL with $_GET method
  • Wordpress always load same page - index.php
  • Find value in array and return with new from different array
  • PHP multiple file upload with different keys
  • Can't modify times one a time without weird errors
  • Get size of scraped image with domcrawler (Goutte)
  • Laravel - Ordering a collection of models
  • PHP Fatal error: Uncaught Error: Call to a member function setFetchMode() on boolean
  • Strict Standards: Only variables should be passed by reference in /main_dir/sub_dir/backup.php
  • Uncaught Google_Exception: (update) unknown parameter: 'copyRequiresWriterPermission'
  • Laravel 5 form does not redirect with old input
  • How to get values greater than or equal to in Mysql database sql when its a value like 1:00 PM?
  • PHP datediff overday issue
  • Masking an auto incrementing primary key
  • How to grab a String BEFORE a certain word
  • ZF2 Routing Multiple Controllers based on route constraints
  • How to deregister/dequeue jquery.sticky.js in Elementor (Pro)?
  • How to fix errors counting words in text plain with PHP?
  • How to get View data in Laravel in custom helper or directive
  • Creating a new data entry into a database with eloquent and trying to access the variable in the url
  • How to test authentication using Laravel Dusk?
  • PHP parse_str not getting all $_GET variables
  • Variable issues in php class
  • Get orders between dates in Codeigniter
  • Eloquent Special Chars Issue
  • Keeping leading zeros column Mysql
  • Current level navigation in Wordpress
  • Add a custom text to WooCommerce cart items if the product has a specific shipping class
  • Error connecting to CommissionJunction Token : [60] SSL certificate problem: unable to get local issuer certificate
  • How do I add a new key value pair to an object in PHP?
  • Http post request to php with dart
  • How to add a route in with blade into parameters of a component
  • How can i get the source of a 777 - CHMOD php file?
  • Convert 2010-04-16 16:30:00 to "Tomorrow Afternoon"
  • How can I hide a $_GET variable to be more secured in PHP?
  • Login to Gmail Inbox using Curl?
  • Upload Excel or CSV file to MySQL with PHP
  • Outlook Marking Email as Junk Email
  • shadow
    Privacy Policy - Terms - Contact Us © scrbit.com