Search results for: 'cms+services'
Results in Category pages.
Results in Magefan Blog.
-
Magento 2: Search Repository using SearchCriteriaBuilder, Filter & FilterGroup
This article shows how we can search Magento Repositories using SearchCriteriaBuilder that implements SearchCriteriaInterface. An example is provided of how we can perform search on Product repository in Magento. Similarly, we can search for other entities like Category, Customer, Order, Invoice, CMS Page, CMS Block, etc.
We can add different conditions to build custom search criteria.
Filters
Filter class is used to add custom field, value, and condition type to the search criteria.
$filter ->setField("name") ->setValue("%laptop%") ->setConditionType("like");condition_typeis optional.- If
condition_typeis not provided then the defaultcondition_typeis set aseq.
Different condition types:
CONDITION NOTES eq Equals gt Greater than gteq Greater than or equal lt Less than lteq Less than or equal moreq More or equal neq Not equal in The value can contain a comma-separated list of values. nin Not in. The value can contain a comma-separated list of values. like The value can contain the SQL wildcard characters when like is specified. nlike Not like notnull Not null null Null finset A value within a set of values nfinset A value that is not within a set of values. from The beginning of a range. Must be used with to. to The end of a range. Must be used with from.Filter Groups
FilterGroup class is used to apply multiple search criteria filters.
For
ORcondition: Pass filters array inside the FilterGroup class object.
ForANDcondition: Pass filterGroups array inside the searchCriteria class object.$filter1 ->setField("name") ->setValue("%laptop%") ->setConditionType("like"); $filter2 ->setField("store_id") ->setValue("1") ->setConditionType("eq"); $filterGroup1->setFilters([$filter1, $filter2]); $filter3 ->setField("url_type") ->setValue(1) ->setConditionType("eq"); $filterGroup2->setFilters([$filter3]); $searchCriteria->setFilterGroups([$filterGroup1, $filterGroup2]);The above code will generate the following conditions:
(name like %laptop% OR store_id eq 1) AND (url_type eq 1)Sorting
SortOrder is used to apply sorting to the search criteria.
Field and Direction can be passed to the sortOrder object.
Field is the name of the field to sort.
Direction is how we would like to sort the result. The two sorting values areASCandDESC.$sortOrder ->setField("email") ->setDirection("ASC"); $searchCriteria->setSortOrders([$sortOrder]);Pagination
Limit the number in the result.
$searchCriteria->setPageSize(20); //retrieve 20 or less entitiesSet the current page
$searchCriteria ->setPageSize(20) ->setCurrentPage(2); //show the 21st to 40th entityThe search engine determines the maximum number of results that a query can return.
For Elasticsearch, the default value of10000is defined in the module’setc/di.xmlfile.Search Items Using Filters
Below is an example of how we can search Product Repository using Search Criteria Builder.
The ProductRepositoryInterface class has the
getList(SearchCriteria $searchCriteria)function which returns the search result object. The object is an instance of the class that implements the interface SearchResultInterface.FilterBuilder and SearchCriteriaBuilder are used to avoid shared instances, i.e. we will be using
create()method in the builder object so that Magento will instantiate a new object (unshared object).use Magento\Framework\Api\SearchCriteriaBuilder; use Magento\Framework\Api\FilterBuilder; use Magento\Catalog\Api\ProductRepositoryInterface; use Magento\Catalog\Api\Data\ProductInterface; ... ... $filter = $this->filterBuilder ->setField(ProductInterface::NAME) ->setValue('%headphone%') ->setConditionType('like') ->create(); $this->searchCriteriaBuilder->addFilters([$filter]); $this->searchCriteriaBuilder->setPageSize(20); $searchCriteria = $this->searchCriteriaBuilder->create(); $productsItems = $this->productRepository ->getList($searchCriteria) ->getItems();Search Items using FilterGroups
Using FilterGroups to add multiple
ANDandORconditions to search products.use Magento\Framework\Api\SearchCriteriaBuilder; use Magento\Framework\Api\FilterBuilder; use Magento\Framework\Api\Search\FilterGroupBuilder; use Magento\Catalog\Api\ProductRepositoryInterface; use Magento\Catalog\Api\Data\ProductInterface; ... ... $filter1 = $this->filterBuilder ->setField(ProductInterface::NAME) ->setValue("%laptop%") ->setConditionType("like") ->create(); $filter2 = $this->filterBuilder ->setField("store_id") ->setValue("1") ->setConditionType("eq") ->create(); $filterGroup1 = $this->filterGroupBuilder ->setFilters([$filter1, $filter2]); $filter3 = $this->filterBuilder ->setField("url_type") ->setValue(1) ->setConditionType("eq") ->create(); $filterGroup2 = $this->filterGroupBuilder ->setFilters([$filter3]); $this->searchCriteriaBuilder ->setFilterGroups([$filterGroup1, $filterGroup2]); $this->searchCriteriaBuilder->setPageSize(20); $searchCriteria = $this->searchCriteriaBuilder->create(); $productsItems = $this->productRepository ->getList($searchCriteria) ->getItems();Product Repository
use Magento\Catalog\Api\ProductRepositoryInterface; use Magento\Catalog\Api\Data\ProductInterface;Category Repository
use Magento\Catalog\Api\CategoryRepositoryInterface; use Magento\Catalog\Api\Data\CategoryInterface;CMS Page Repository
use Magento\Cms\Api\PageRepositoryInterface; use Magento\Cms\Api\Data\PageInterface;CMS Block Repository
use Magento\Cms\Api\BlockRepositoryInterface; use Magento\Cms\Api\Data\BlockInterface;Customer Repository
use Magento\Customer\Api\CustomerRepositoryInterface; use Magento\Customer\Api\Data\CustomerInterface;Order Repository
use Magento\Sales\Api\OrderRepositoryInterface; use Magento\Sales\Api\Data\OrderInterface; -
How To Add Banner Ads To Ionic Apps Using AdMob Pro Plugin
In this post I will show how you can add banner ads to your Ionic apps. I will be doing this on a new app but you can do it to your existing app as well. I have also written a post on adding banner ads to Ionic 2 apps, so if you are looking for Ionic 2 apps You can check that post out as well.
Step 1)
We will first start by creating a new Ionic project by issuing the following command in the command prompt
1ionic start MyNewApp TabsStep 2)
Now we will need to add the platform to out app. So will do the following command
Step 3)
As we will be using the AdMob Pro plugin we will need to download it in our project. We will do that by the following command
you can read more about the plugin in the Admob pro plugin documentation
Step 4)
Now we will need to add the following code to the $ionicPlatform.ready() in the app.js file
So the finished app.js file looks like this:
NOTE: The app.js file will be different for each template namely tabs,bank,sideMenu, make sure you add the code to the $ionicPlatform.ready() function and no to any function inside it.
-
All in one Magento Integrated Search
Magento CMS & nBlog Integrated Search extension includes your nBlog blog posts and Magento CMS pages. This extension is useful to make your store more interactive and reduces user bounce rate.
After install extension go to System -> Index Management .
In Index Management check “Rebuild nBlog fulltext search index” click “Reindex Data”if you are not install the supported magento extension nBlog,Samdoit_Portfolio the Search Setting
are look like the following image.After install the supported extension (nblog,samdoit_portfolio) the setting will be look like the following image.
-
Changing PHP version with Valet and Homebrew (OSX)
Recently, I updated the PHP on my machine to version 7.4 using homebrew for Mac OS only to then realise that one of my older projects that I still needed to maintain, made on version 7.2 would no longer work due to using depreciated PHP functions such as array_key_exists.
The long term solution to this would be to update the project so it’s compatible with PHP version 7.4, but for the sake of time, and potential fixes that needed to go out immediately, I needed to be able to develop this project in the environment it’s running in. Fortunately, I use valet to develop all my PHP applications a tool I can only recommend for PHP developers. Valet allows you to develop PHP applications on your local machine with a much higher level of ease than I’ve found using other services such as dockers or XAMP/MAMP.
Valet, with the use of homebrew, supports switching your system PHP version at will to any version installable via homebrew. So switching versions can be as simple as the following:
brew search php
This will show you all the versions of PHP available via brew, the “php” package represents the latest stable PHP version (which at the time of writing is 7.4) you can also see that versions 7.2 and 7.3 are available and I have them installed.
If you do not yet have the PHP version installed, you can install it by entering:brew install php@7.2
Once installed, you can then use this with valet. By default, valet will use the system PHP version however you can override this by running:
valet use php@7.2
You should then see various outputs that look like the following:
Now you can check that your PHP version has changed:php -v
You should see your PHP version has changed:
It’s as simple as that!That’s how you can quickly and easily switch your PHP version using valet and homebrew. Your computer may need a reboot if the change does not seem to take affect, I have only encountered this once in my experience though.
So the only question that remains now is, how do I get back to where I was?
Reverting back to the latest PHP
Once you have finished developing, you’re likely going to want to return to the latest version of PHP for your modern/new applications. Doing this is as simple as downgrading, just tell valet to use “php”, which as we discovered earlier, is the latest version of PHP. So lets run that:
valet use php
As before, you should see an output like the following:
php -v
You should see your PHP version has reverted.
-
MySQL - SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client (solution)
The default MySQL 8 auth plugin is
auth_socket, which causes the error "SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client" when an application is attempting to log in to the database with a password. Let's go through the steps to fix this.Step 1
Login to the
mysqlserver in sudo mode as the root user and supply any required passwords.sudo mysql -u root -pStep 2
Now run the following
ALTER USERcommand, replacing root with your database user and password if your password.ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';Now run:
FLUSH PRIVILEGES;Now exit the MySQL server:
exit;Step 3
You may need to restart the mysql services for the changes to take effect:
sudo service mysql restart -
Add wysiwyg editor in magento custom module.
Add wysiwyg editor in magento custom module. is very easy to make it in your magento custom modue use this following method to add wysiwyg editor .
go to the file
{your magento root folder}/Block/Adminhtml/{module name}/Edit/Tab/Form.phpadd following code in top of the file
$fieldset->addField('followupemail_text', 'editor', array('name'=>'followupemail_text','label' => Mage::helper('followupemail')->__('Content'),'title' => Mage::helper('followupemail')->__('Content'),'required' => true,'style' => 'height:24em;','config' => $wysiwygConfig, ));go to the file
{your magento root folder}/Block/Adminhtml/{module name}/Edit.phpadd the following line in this file
protected function _prepareLayout(){// Load Wysiwyg on demand and Prepare layoutif (Mage::getSingleton('cms/wysiwyg_config')->isEnabled() && ($block = $this->getLayout()->getBlock('head'))){$block->setCanLoadTinyMce(true);}parent::_prepareLayout();} -
AW Blog Integrated Search
Magento AW Blog Integrated Search extends your default Magento search to include your Magento CMS pages and AW blog posts content in search results. Blog contents are now listed in search results from integrated AW blog to ensure more keywords and content visibility to user. This extension will reduce the user bounce rate and keep your search more interactive and effective than before. You can add following results in default search in Magento
- Magento CSM pages
- AW Blog post
- Mage Search Tearm Improvement .
Integrating AW blog to Magento is a common way to have blog, more traffic and many more advantages. AW blog extension is well known for an effective blog in Magento community. Magento AW blog Integrated Search is compatible with AW blog extension.
How to Use this Extension
After install extension go to System -> Index Management .
In Index Management check “AW Blog Search Index” click “Reindex Data”Customer can view the search result in front end using default magento search.








