Skip to content

Instantly share code, notes, and snippets.

@klevu
klevu / LoadAttributeOverride.php
Last active December 19, 2023 13:06
Klevu V2/V3 : To send extra information to Klevu on product level
<?php
//File: Acme/MyModule/Model/Product/LoadAttributeOverride.php
namespace Acme\MyModule\Model\Product;
use Klevu\Search\Api\Provider\Sync\ReservedAttributeCodesProviderInterface;
use Klevu\Search\Api\Service\Catalog\Product\StockServiceInterface;
use Klevu\Search\Model\Context as KlevuContext;
use Klevu\Search\Model\Klevu\KlevuFactory;
use Klevu\Search\Model\Product\LoadAttribute as OriginalLoadAttribute;
use Klevu\Search\Model\Product\ProductInterface as KlevuProductData;
@klevu
klevu / klevu-sync-debug
Last active June 10, 2022 10:56
bin/klevu-sync-debug
#!/usr/bin/env php
<?php
use Klevu\Search\Api\KlevuSyncRepositoryInterface;
use Klevu\Search\Api\MagentoProductSyncRepositoryInterface;
use Magento\Eav\Model\Entity;use Magento\Framework\App\Bootstrap;
use Magento\Store\Api\Data\StoreInterface;
if (PHP_SAPI !== 'cli') {
echo 'bin/klevu-sync-debug must be run as a CLI application';
@klevu
klevu / Page: search-results
Last active May 5, 2023 17:55
Shopify Assets
<div class='kuContainer' id='kuMainContainer'><div id='ku-search-form' class='ku-search-block-full' style='display:none;'><form action='/pages/search-results' method='get' role='search'><input type='search' name='q' id='ku-search-field' class='ku-searchfield' placeholder='Search text'><input type='button' title='Search' id='ku-search-btn' value='' class='ku-search-btn'></form></div><div class='klevu-clear-both'></div><div id='loader' style='text-align:center'><img src='https://js.klevu.com/klevu-js-v1/img-1-1/ku-loader.gif' alt='Loading...'/></div><div class='kuNoRecordFound' id='kuNoRecordFound' style='display:none;'><p>No matching products found.</p></div><div class='kuProListing' id='kuProListing' style='display: none;'><div class='kuFilterHead kufilter-label' id='klevuNarrowByLabel'>Narrow By</div><div class='kuFilters' id='kuFilters'></div><div id='ku-search-filter-tags'></div><div class='kuResultList' id='kuResultListBlock'><div class='kuResultInfo'><div class='kuTotalResultsTab' id='kuTotResults'><div
@klevu
klevu / GraphQL Query
Created June 23, 2020 16:01
Shopify Blog - Faster Metafields 5
mutation {
bulkOperationRunQuery(
query: """
{
products {
edges {
node {
id
metafields {
edges {
@klevu
klevu / GraphQL Query
Created June 23, 2020 15:45
Shopify Blog - Faster Metafields 4
{
productVariants(first: 50) {
pageInfo {
hasNextPage
}
edges {
cursor
node {
legacyResourceId
product {
@klevu
klevu / GraphQL Timings
Created June 23, 2020 15:42
Shopify Blog - Faster Metafields 3
0.0s: Fetch the first 30 products: ~0.5 seconds
0.5s: Query bucket ~300, wait 8 seconds for refill to ~700
8.5s: Fetch the next 30 products: ~0.5 seconds
9.0s: Query bucket ~0, wait 14 seconds for refill to ~700
23.0s: Fetch the next 30 products: ~0.5 seconds
23.5s: Query bucket ~0, wait 14 seconds for refill to ~700
37.5s: Fetch the final 10 products: ~0.5 seconds
@klevu
klevu / GraphQL Query
Created June 23, 2020 15:35
Shopify Blog - Faster Metafields 2
{
products(first: 250) {
edges {
node {
metafields(first: 250) {
edges {
node {
namespace
key
value
@klevu
klevu / GraphQL Query
Created June 23, 2020 15:33
Shopify Blog - Faster Metafields 1
{
product(first: 50) {
edges {
node {
name
description
}
}
}
}
@klevu
klevu / query-1
Last active February 12, 2024 12:00
Shopify Metafields with GraphQL
{
product(first: 50) {
edges {
node {
name
description
}
}
}
}