Collection of the Laravel/Eloquent Model classes that allows you to get data directly from a Magento 2 database.

Overview

Laragento LAravel MAgento Micro services

Magento 2 has legacy code based on abandoned Zend Framework 1 with really ugly ORM on top of outdated Zend_DB. Zend_DB is not even in the latest version.

This repo is a collection of Model classes that allows you to get data directly from a Magento 2 database using modern ORM.

Laragento is a collection of PHP classes built on top of Eloquent ORM (from Laravel framework), that provides a fluent interface to connect and get data directly from a Magento database.

You can use legacy MAgento 2 as the backend (administration panel), and any other PHP app (Symfony/Laravel/Lumen/Vanilla.PHP etc.) and query that data (as a Model layer). It's easier to use Laragento with Laravel, but you're free to use it with any PHP project using Composer.

History

After releases of the VueStorefron and Hyva Theme (A brand-new frontend for Magento 2 without reusing magento UI and using Laravel ecosystem as a base Alpine.JS / Tailwind CSS) everybody understands that the only way to build a good eCommerce Website is not to use M2 broken legacy frontend/backend functionality. I have been using this library for the last 3 years and see only benefits. Even if you need reimplement functionality from scratch it is much faster than reusing Adobe Commerce broken core framework bloatware.

Why Laravel and Eloquent?

Laravel is the most popular PHP framework. I have used different ORMs and Eloquent is the best.

Magento ORM Concept

Data is the essence of any web application. Models are the essence of the ORM. A model is an abstraction that represents a magento table in the database. In Larafento, it is a class that extends base Eloquent/Model.

The model tells Eloquent several things about the entity it represents, such as the name of the table in the database and optionally which columns it has (and their data types).

A model has a name. This name does not have to be the same name of the Magento table it represents in the database. catalog_product_entity -> CatalogProductEntity.

Extand Base Magento Model

Customisations involves creating new Eloquent models that extend Magento base models. By extending a model, you inherit the full functionality of the parent model, while retaining the ability to add customisation, scopes, event listeners, etc. Also Repository patern can be used but it is anther storry. A base model represents a Datase table operation only.

class ProductSimple extends CatalogProductEntity
{
   public static function boot()
    {
        parent::boot();

        static::addGlobalScope(function ($query) {
            $query->where('type_id', 'simple');
        });
    }
    
   public function getBySku(string $sku) {
        $this->where('sku', $sku);
   }
}

Documentation

This solution doesn't require documentation because it reuses a widely used software development tools vs Magento 2 in house built framework.

Official Eloquent Documentation: https://laravel.com/docs/8.x/eloquent

If you have any issues and Enterprise (Adobe Commerce) Version support create a ticket or drop me email at: [email protected]

Install Laragento

You need to use Composer to install Laragento into your project:

composer config repositories.foo '{"type": "vcs", "url": "https://github.com/Genaker/laragento", "trunk-path": "master"}'
composer require Genaker/laragento

Other PHP Framework (not Laravel and Magento) Setup

Here you have to configure the database to work with MAgento. First, you should include the Composer autoload file if not already loaded:

require __DIR__ . '/vendor/autoload.php';

Now you must set your Magento2 database params:

$params = array(
    'database'  => 'database_name',
    'username'  => 'username',
    'password'  => 'pa$$word',
    'prefix'    => '' 
);
Laragento\DB::connect($params);

You can specify all Eloquent params, but some are default (but you can override them).

'driver'    => 'mysql',
'host'      => 'localhost',
'charset'   => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix'    => '', 

However it will be better to use it as a separate Magento-les microservice entry point in the separate directory together with Laravel or Lumen.

LAravel MAgento with Tinker (REPL)

Laravel Tinker is a powerful REPL for the Laravel framework, powered by the PsySH package.

Tinker Installation

All Laravel applications include Tinker by default. However, you may install Tinker using Composer if you have previously removed it from your application:

composer create-project laravel/laravel laragento 
cd laragento
composer require laravel/tinker
composer config repositories.foo '{"type": "vcs", "url": "https://github.com/Genaker/laragento", "trunk-path": "master"}'
composer require Genaker/laragento

Set proper DB connect in the .env file:

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=root
DB_PASSWORD=

Tinker Usage

Tinker allows you to interact with your entire Laravel application on the command line, including your Eloquent models (Laragento), jobs, events, and more. To enter the Tinker environment, run the tinker Artisan command:

php artisan tinker

$products = Laragento\Models\CatalogProductEntity::first();

$products = Laragento\Models\CatalogProductEntity::where('sku', '21157');

$products = Laragento\Models\CatalogProductEntity::where('sku', '21157')->with('catalog_product_entity_varchars')->get();

$orders = Laragento\Models\SalesOrder::limit(10)->with('sales_order_items', 'sales_invoices', 'sales_order_payments', 'sales_creditmemos', 'sales_order_addresses', 'sales_shipments', 'customer_entity')->get(); 
$orders->toJson();

$creditMemo = Laragento\Models\SalesCreditmemo::limit(1)->with('sales_order','sales_creditmemo_items','sales_creditmemo_comments', 'sales_creditmemo_items')->get(); $creditMemo->toArray()

$invoices = Laragento\Models\SalesInvoice::limit(1)->with('sales_order','sales_invoice_items','sales_invoice_comments')->get(); $invoices->toJson();

Example of the Magento Order to ERM implementation

require __DIR__ . '/vendor/autoload.php';

$orders = Laragento\Models\SalesOrder::whereNull('sync_status')->with('sales_order_items', 'sales_invoices', 'sales_order_payments', 'sales_creditmemos', 'sales_order_addresses', 'sales_shipments', 'customer_entity', 'sales_payment_transactions')->get();
 
foreach ($oreders as $order) {
    $response = $erp->orderAPI($order->toJson());
    if ($response->responseCode === 200) {
        $order->sync_status = 'sent_to_erp';
        $order->save();
    } else {
        echo "Error";
    }
}

No ObjectManager, DI and other stuff required.

Laravel/Eloquent and static::methods

Some Magento 2 bloatware lovers hate static methods. For those guys Laravel has a solution...

Static Example:

$user = User::find(1);
var_dump($user->name);

Laravel isn't using a static method, you are. Another way to do this which you are probably looking for is to use dependency injection, which Laravel makes very easy because it can be done automatically. So in whatever class you are using your User model in, you should be setting up something like this in the constructor...

public function __construct(User $user)
{
    $this->user = $user;
}

And then you can modify your code to not use the static bindings.

$user = $this->user->find(1);
var_dump($user->name);

More about Eloquent you can watch here:

https://www.youtube.com/watch?v=uyQH90okBNQ&list=PL8nVHL94VZ18EGJX9iSR01Xx7vgzX6Uar

Integration with Magento 2 / 1 Framework

Install this ORM to the separate folder

mkdir orm
cd orm
composer require genaker/laragento @dev

Run this command. Magento 2 uses outdated Monolog version and has conflict in the composers:

find ./orm/vendor/ -type f -exec sed -i -e 's/Monolog/Monolog2/g' {} \;
mv ./orm/vendor/monolog/monolog/src/Monolog/ vendor/monolog/monolog/src/Monolog2/

add to the app/bootstrap.php additional autoloader

# After This
require_once __DIR__ . '/autoload.php';
# Insert This
require_once __DIR__ . '/../orm/vendor/autoload.php';

Overhead of loading LAravel with 100 product in magento is : 0.0051751136779785 seconds 10 products: 0.0026481151580811 seconds. Just autoload: 0.00015616416931152 seconds. So, there is no overhead of adding this life hack to Magento. Magento 2 framework is an instinct dinosaur.

Magento GraphQL for Laravel/Eloquent

Lighthouse is a GraphQL framework that integrates with MAgento Eloquent Laravel application. It takes the best ideas of both and combines them to solve common tasks with ease and offer flexibility when you need it.

More information:

https://lighthouse-php.com/

It is really Cool Magento developers can enjoy building modern software and not just debug and troubleshoot broken MAgento 2

Debug Queries using the Laravel Query Log

Laravel query log that collects all queries within a request. You can enable this log, run your query and dump the output.

DB::enableQueryLog();

App\User::query()
    ->where('created_at', '<', now()->subYear())
    ->with('assignedApps', 'courses')
    ->orderBy('email', 'asc')
    ->limit(5)
    ->get();

dump(DB::getQueryLog());

Listening For Query Events

If you would like to receive each SQL query executed by your application, you may use the listen method. This method is useful for logging queries or debugging. You may register your query listener in a service provider:

app/Providers/AppServiceProvider.php

<?php

namespace App\Providers;

use Illuminate\Support\Facades\DB;
use Illuminate\Support\ServiceProvider;

class AppServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        DB::listen(function ($query) {
           var_dump(
                $query->sql,
                $query->bindings,
                $query->time
            );
        });
    }

    /**
     * Register the service provider.
     *
     * @return void
     */
    public function register()
    {
        //
    }
}
Comments
  • Need to discuss in Magento forums

    Need to discuss in Magento forums

    I think you need to discuss with Magento team directly,we need to convey them,so that directly we can contribute to Magento codebase directly in some other branch.so if everything fine and stable they can merge into main release branch.

    opened by sivajik34 2
  • Magento Search Re-index SQL - Product-EAV

    Magento Search Re-index SQL - Product-EAV

    SELECT catalog_product_index_price.entity_id, catalog_product_index_price.customer_group_id, catalog_product_index_price.website_id, catalog_product_index_price.min_price FROM catalog_product_index_price WHERE (entity_id IN ()) - > []

    SELECT e.entity_id, e.type_id, e.sku FROM catalog_product_entity AS e INNER JOIN catalog_product_website AS website ON website.product_id = e.entity_id AND website.website_id = 4 INNER JOIN cataloginventory_stock_status AS stock_index ON stock_index.product_id = e.entity_id INNER JOIN catalog_product_entity_int AS visibility_default ON visibility_default.row_id= e.row_id AND visibility_default.attribute_id = '102' AND visibility_default.store_id = 0 LEFT JOIN catalog_product_entity_int AS visibility_store ON visibility_store.row_id= e.row_id AND visibility_store.attribute_id = '102' AND visibility_store.store_id = 4 INNER JOIN catalog_product_entity_int AS status_default ON status_default.row_id= e.row_id AND status_default.attribute_id = '96' AND status_default.store_id = 0 LEFT JOIN catalog_product_entity_int AS status_store ON status_store.row_id= e.row_id AND status_store.attribute_id = '96' AND status_store.store_id = 4 WHERE ((IF(visibility_store.value_id > 0, visibility_store.value, visibility_default.value) IN (3, 2, 4)) AND (IF(status_store.value_id > 0, status_store.value, status_default.value) IN (1)) AND (e.entity_id > 115324) AND (e.entity_id < 117825)) AND (e.created_in <= '1630438980') AND (e.updated_in > '1630438980') ORDER BY e.entity_id ASC

    SELECT DISTINCT t.row_id, t.attribute_id, IF(t_store.value_id > 0, t_store.value, t_default.value) AS value FROM catalog_product_entity_int AS t LEFT JOIN catalog_product_entity_int AS t_store ON t.row_id=t_store.row_id AND t.attribute_id=t_store.attribute_id AND t_store.store_id = '4' LEFT JOIN catalog_product_entity_int AS t_default ON t.row_id=t_default.row_id AND t.attribute_id=t_default.attribute_id AND t_default.store_id = 0 WHERE (t.attribute_id IN (1319, 624 )) UNION ALL SELECT DISTINCT t.row_id, t.attribute_id, IF(t_store.value_id > 0, t_store.value, t_default.value) AS value FROM catalog_product_entity_varchar AS t LEFT JOIN catalog_product_entity_varchar AS t_store ON t.row_id=t_store.row_id AND t.attribute_id=t_store.attribute_id AND t_store.store_id = '4' LEFT JOIN catalog_product_entity_varchar AS t_default ON t.row_id=t_default.row_id AND t.attribute_id=t_default.attribute_id AND t_default.store_id = 0 WHERE (t.attribute_id IN (1313, 1301, )) UNION ALL SELECT DISTINCT t.row_id, t.attribute_id, IF(t_store.value_id > 0, t_store.value, t_default.value) AS value FROM catalog_product_entity_text AS t LEFT JOIN catalog_product_entity_text AS t_store ON t.row_id=t_store.row_id AND t.attribute_id=t_store.attribute_id AND t_store.store_id = '4' LEFT JOIN catalog_product_entity_text AS t_default ON t.row_id=t_default.row_id AND t.attribute_id=t_default.attribute_id AND t_default.store_id = 0 WHERE (t.attribute_id IN (72, 83, 73, 343, 332)) AND (t.row_id IN (2039, 11192, )) UNION ALL SELECT DISTINCT t.row_id, t.attribute_id, IF(t_store.value_id > 0, t_store.value, t_default.value) AS value FROM catalog_product_entity_decimal AS t LEFT JOIN catalog_product_entity_decimal AS t_store ON t.row_id=t_store.row_id AND t.attribute_id=t_store.attribute_id AND t_store.store_id = '4' LEFT JOIN catalog_product_entity_decimal AS t_default ON t.row_id=t_default.row_id AND t.attribute_id=t_default.attribute_id AND t_default.store_id = 0 WHERE (t.attribute_id IN (75)) AND (t.row_id IN (......))

    SELECT u.* FROM ( (SELECT t.value, t.attribute_id, t.store_id FROM catalog_category_entity_text AS t WHERE (row_id = '8183') AND (attribute_id IN (743, 746, 764, 749, 752, 1406, 755, 1409, 758, 1410, 44, 761, 1411, 1412, 1413, 47, 1414, 48, 54, 55, 56, 1424, 1425, 1428, 1440, 1441, 1443, 1444, 65, 721, 62, 1075, 711, 1079, 713, 1083, 1085, 715, 716)) AND (store_id IN ('4', 0)))UNION ALL(SELECT t.value, t.attribute_id, t.store_id FROM catalog_category_entity_varchar AS t WHERE (row_id = '8183') AND (attribute_id IN (41, 1408, 43, 45, 46, 1415, 1416, 49, 58, 701, 1063, 1417, 1429, 1418, 1419, 1431, 1432, 1420, 1421, 1422, 57, 718, 1065, 1434, 1438, 1439, 1457, 1442, 705, 719, 1445, 720, 800, 1069, 133, 61, 66, 1071, 1139, 1073, 709, 710, 1077, 425, 1081, 660, 1087, 1089, 1091, 1375, 1378, 1381, 1387, 1390)) AND (store_id IN ('4', 0)))UNION ALL(SELECT t.value, t.attribute_id, t.store_id FROM catalog_category_entity_int AS t WHERE (row_id = '8183') AND (attribute_id IN (42, 1407, 1446, 1447, 68, 69, 67, 703, 717, 1448, 1430, 1433, 1450, 1423, 1451, 1452, 50, 1435, 1426, 1436, 1427, 1437, 1456, 51, 1067, 1061, 1400, 426, 428, 1384)) AND (store_id IN ('4', 0)))UNION ALL(SELECT t.value, t.attribute_id, t.store_id FROM catalog_category_entity_datetime AS t WHERE (row_id = '8183') AND (attribute_id IN (59, 60, 656, 657)) AND (store_id IN ('4', 0)))UNION ALL(SELECT t.value, t.attribute_id, t.store_id FROM catalog_category_entity_decimal AS t WHERE (row_id = '8183') AND (attribute_id IN (70)) AND (store_id IN ('4', 0))) ) AS u ORDER BY store_id ASC

    SELECT u.* FROM ( (SELECT t.value, t.attribute_id, t.store_id FROM catalog_category_entity_text AS t WHERE (row_id = '7279') AND (attribute_id IN (743, 746, 764, 749, 752, 1406, 755, 1409, 758, 1410, 44, 761, 1411, 1412, 1413, 47, 1414, 48, 54, 55, 56, 1424, 1425, 1428, 1440, 1441, 1443, 1444, 65, 721, 62, 1075, 711, 1079, 713, 1083, 1085, 715, 716)) AND (store_id IN ('4', 0)))UNION ALL(SELECT t.value, t.attribute_id, t.store_id FROM catalog_category_entity_varchar AS t WHERE (row_id = '7279') AND (attribute_id IN (41, 1408, 43, 45, 46, 1415, 1416, 49, 58, 701, 1063, 1417, 1429, 1418, 1419, 1431, 1432, 1420, 1421, 1422, 57, 718, 1065, 1434, 1438, 1439, 1457, 1442, 705, 719, 1445, 720, 800, 1069, 133, 61, 66, 1071, 1139, 1073, 709, 710, 1077, 425, 1081, 660, 1087, 1089, 1091, 1375, 1378, 1381, 1387, 1390)) AND (store_id IN ('4', 0)))UNION ALL(SELECT t.value, t.attribute_id, t.store_id FROM catalog_category_entity_int AS t WHERE (row_id = '7279') AND (attribute_id IN (42, 1407, 1446, 1447, 68, 69, 67, 703, 717, 1448, 1430, 1433, 1450, 1423, 1451, 1452, 50, 1435, 1426, 1436, 1427, 1437, 1456, 51, 1067, 1061, 1400, 426, 428, 1384)) AND (store_id IN ('4', 0)))UNION ALL(SELECT t.value, t.attribute_id, t.store_id FROM catalog_category_entity_datetime AS t WHERE (row_id = '7279') AND (attribute_id IN (59, 60, 656, 657)) AND (store_id IN ('4', 0)))UNION ALL(SELECT t.value, t.attribute_id, t.store_id FROM catalog_category_entity_decimal AS t WHERE (row_id = '7279') AND (attribute_id IN (70)) AND (store_id IN ('4', 0))) ) AS u ORDER BY store_id ASC

    SELECT cpe.row_id, cpe.entity_id FROM catalog_product_entity AS cpe WHERE ((cpe.entity_id IN (117190, 117195, 117201, 117204, 117207, ...))) AND (cpe.created_in <= '1630438980') AND (cpe.updated_in > '1630438980') - > []
    SQL time [0.00033807754516602]
    SELECT DISTINCT t.row_id, t.attribute_id, IF(t_store.value_id > 0, t_store.value, t_default.value) AS value FROM catalog_product_entity_int AS t LEFT JOIN catalog_product_entity_int AS t_store ON t.row_id=t_store.row_id AND t.attribute_id=t_store.attribute_id AND t_store.store_id = '4' LEFT JOIN catalog_product_entity_int AS t_default ON t.row_id=t_default.row_id AND t.attribute_id=t_default.attribute_id AND t_default.store_id = 0 WHERE (t.attribute_id IN (1319, 624, 420, 463, ....)) UNION ALL SELECT DISTINCT t.row_id, t.attribute_id, IF(t_store.value_id > 0, t_store.value, t_default.value) AS value FROM catalog_product_entity_varchar AS t LEFT JOIN catalog_product_entity_varchar AS t_store ON t.row_id=t_store.row_id AND t.attribute_id=t_store.attribute_id AND t_store.store_id = '4' LEFT JOIN catalog_product_entity_varchar AS t_default ON t.row_id=t_default.row_id AND t.attribute_id=t_default.attribute_id AND t_default.store_id = 0 WHERE (t.attribute_id IN (1313, 1301, 1307, 1295, 410, 84, 82, 727, 71, 1026, 413, 97, 1229)) AND (t.row_id IN (5600, 17314, 19355, ....)) UNION ALL SELECT DISTINCT t.row_id, t.attribute_id, IF(t_store.value_id > 0, t_store.value, t_default.value) AS value FROM catalog_product_entity_text AS t LEFT JOIN catalog_product_entity_text AS t_store ON t.row_id=t_store.row_id AND t.attribute_id=t_store.attribute_id AND t_store.store_id = '4' LEFT JOIN catalog_product_entity_text AS t_default ON t.row_id=t_default.row_id AND t.attribute_id=t_default.attribute_id AND t_default.store_id = 0 WHERE (t.attribute_id IN (72, 83, 73, 343, 332)) AND (t.row_id IN (5600, 17314, 19355, 19381, 58763, 39463, 51842 ....)) UNION ALL SELECT DISTINCT t.row_id, t.attribute_id, IF(t_store.value_id > 0, t_store.value, t_default.value) AS value FROM catalog_product_entity_decimal AS t LEFT JOIN catalog_product_entity_decimal AS t_store ON t.row_id=t_store.row_id AND t.attribute_id=t_store.attribute_id AND t_store.store_id = '4' LEFT JOIN catalog_product_entity_decimal AS t_default ON t.row_id=t_default.row_id AND t.attribute_id=t_default.attribute_id AND t_default.store_id = 0 WHERE (t.attribute_id IN (75)) AND (t.row_id IN (5600, 17314, 19355, .....))

    opened by Genaker 0
  • Stock/Inventory SQL

    Stock/Inventory SQL

    SELECT main_table.*, cp_table.type_id FROM cataloginventory_stock_item AS main_table INNER JOIN catalog_product_entity AS cp_table ON main_table.product_id = cp_table.entity_id AND (cp_table.created_in <= '1630438980' AND cp_table.updated_in > '1630438980') WHERE (main_table.product_id IN('109340')) - > []

    SELECT main_table.*, cp_table.sku, cp_table.type_id FROM cataloginventory_stock_status AS main_table INNER JOIN catalog_product_entity AS cp_table ON main_table.product_id = cp_table.entity_id AND (cp_table.created_in <= '1630438980' AND cp_table.updated_in > '1630438980') WHERE (main_table.product_id IN('109340')) AND (main_table.website_id = '0') - > []

    SELECT e.*, stock_status_index.stock_status AS is_salable FROM catalog_product_entity AS e LEFT JOIN cataloginventory_stock_status AS stock_status_index ON e.entity_id = stock_status_index.product_id AND stock_status_index.website_id = 0 AND stock_status_index.stock_id = 1 WHERE ((e.entity_id = '109340')) AND (e.created_in <= '1630438980') AND (e.updated_in > '1630438980') - > []

    SELECT e.*, price_index.price, price_index.tax_class_id, price_index.final_price, IF(price_index.tier_price IS NOT NULL, LEAST(price_index.min_price, price_index.tier_price), price_index.min_price) AS minimal_price, price_index.min_price, price_index.max_price, price_index.tier_price, cat_index.position AS cat_index_position, stock_status_index.stock_status AS is_salable, links.link_id, links.product_id AS _linked_to_product_id, link_attribute_position_int.value AS position FROM catalog_product_entity AS e INNER JOIN catalog_product_index_price AS price_index ON price_index.entity_id = e.entity_id AND price_index.customer_group_id = 0 AND price_index.website_id = '1' INNER JOIN catalog_category_product_index_store1 AS cat_index ON cat_index.product_id=e.entity_id AND cat_index.store_id=1 AND cat_index.visibility IN(2, 4) AND cat_index.category_id=2 LEFT JOIN cataloginventory_stock_status AS stock_status_index ON e.entity_id = stock_status_index.product_id AND stock_status_index.website_id = 0 AND stock_status_index.stock_id = 1 INNER JOIN catalog_product_link AS links ON links.linked_product_id = e.entity_id AND links.link_type_id = 1 LEFT JOIN catalog_product_link_attribute_int AS link_attribute_position_int ON link_attribute_position_int.link_id = links.link_id AND link_attribute_position_int.product_link_attribute_id = '1' INNER JOIN catalog_product_entity AS product_entity_table ON links.product_id = product_entity_table.row_id AND (product_entity_table.created_in <= '1630438980' AND product_entity_table.updated_in > '1630438980') WHERE ((e.entity_id NOT IN('109340')) AND (links.product_id in (81983)) AND (e.row_id != '81983')) AND (e.created_in <= '1630438980') AND (e.updated_in > '1630438980') ORDER BY e.sku ASC LIMIT 20

    SELECT e.*, price_index.price, price_index.tax_class_id, price_index.final_price, IF(price_index.tier_price IS NOT NULL, LEAST(price_index.min_price, price_index.tier_price), price_index.min_price) AS minimal_price, price_index.min_price, price_index.max_price, price_index.tier_price, cat_index.position AS cat_index_position, stock_status_index.stock_status AS is_salable FROM catalog_product_entity AS e INNER JOIN catalog_product_index_price AS price_index ON price_index.entity_id = e.entity_id AND price_index.customer_group_id = 0 AND price_index.website_id = '1' INNER JOIN catalog_category_product_index_store1 AS cat_index ON cat_index.product_id=e.entity_id AND cat_index.store_id=1 AND cat_index.visibility IN(2, 4) AND cat_index.category_id=2 LEFT JOIN cataloginventory_stock_status AS stock_status_index ON e.entity_id = stock_status_index.product_id AND stock_status_index.website_id = 0 AND stock_status_index.stock_id = 1 WHERE ((e.entity_id IN(5690, 2513, 17711, 5174, 32798, 4790, 38782, 38788, 17612, 113135, 5140, 42506, 38779, 106283, 50338, 21245, 24160))) AND (e.created_in <= '1630438980') AND (e.updated_in > '1630438980') LIMIT 17

    SELECT main_table.*, cp_table.type_id FROM cataloginventory_stock_item AS main_table INNER JOIN catalog_product_entity AS cp_table ON main_table.product_id = cp_table.entity_id AND (cp_table.created_in <= '1630438980' AND cp_table.updated_in > '1630438980') WHERE (main_table.product_id IN('49996'))

    opened by Genaker 0
  • Category SQL

    Category SQL

    SELECT catalog_category_product.category_id, catalog_category_product.position FROM catalog_category_product WHERE (product_id = 109340) - > []

    SELECT catalog_category_entity.entity_id FROM catalog_category_entity WHERE ((entity_id = :entity_id)) AND (catalog_category_entity.created_in <= '1630438980') AND (catalog_category_entity.updated_in > '1630438980') - > [2] SQL time [0.00021600723266602] SELECT catalog_category_entity.* FROM catalog_category_entity WHERE ((catalog_category_entity.entity_id = '2')) AND (catalog_category_entity.created_in <= '1630438980') AND (catalog_category_entity.updated_in > '1630438980') - > [] SQL time [0.00021696090698242] SELECT catalog_category_entity.* FROM catalog_category_entity WHERE ((catalog_category_entity.path LIKE '1/2/%')) AND (catalog_category_entity.created_in <= '1630438980') AND (catalog_category_entity.updated_in > '1630438980') ORDER BY catalog_category_entity.position ASC - > [] SQL time [0.0004429817199707] SELECT e.entity_id FROM catalog_category_entity AS e LEFT JOIN catalog_category_entity_varchar AS at_name_default ON (at_name_default.row_id = e.row_id) AND (at_name_default.attribute_id = '41') AND at_name_default.store_id = 0 LEFT JOIN catalog_category_entity_varchar AS at_name ON (at_name.row_id = e.row_id) AND (at_name.attribute_id = '41') AND (at_name.store_id = 1) INNER JOIN catalog_category_entity_int AS d ON e.row_id = d.row_id LEFT JOIN catalog_category_entity_int AS c ON c.attribute_id = :attribute_id AND c.store_id = :store_id AND c.row_id = d.row_id WHERE ((e.entity_id IN('286', '116', )) AND (d.attribute_id = :attribute_id) AND (d.store_id = :zero_store_id) AND (IF(c.value_id > 0, c.value, d.value) = :cond)) AND (e.created_in <= '1630438980') AND (e.updated_in > '1630438980') - > [42 - 1 - 0 - 0]

    EAV:

    SELECT t_d.attribute_id, e.entity_id, t_d.value AS default_value, t_s.value AS store_value, IF(t_s.value_id IS NULL, t_d.value, t_s.value) AS value FROM catalog_category_entity_varchar AS t_d INNER JOIN catalog_category_entity AS e ON e.row_id = t_d.row_id AND (e.created_in <= '1630438980' AND e.updated_in > '1630438980') LEFT JOIN catalog_category_entity_varchar AS t_s ON t_s.attribute_id = t_d.attribute_id AND t_s.row_id = t_d.row_id AND t_s.store_id = 1 WHERE (e.entity_id IN (

    opened by Genaker 0
  • URL Rewrite

    URL Rewrite

    URL Rewrite:

    SELECT url_rewrite.* FROM url_rewrite WHERE (request_path IN ('cameradept/camera-equipment/l', 'cameradept/camera-equipment/')) AND (store_id IN ('1')) - > []

    SELECT url_rewrite.* FROM url_rewrite WHERE (request_path IN ('cameradept/cameral', 'cameradept/camera-equipment//')) AND (store_id IN ('1')) - > []

    SELECT url_rewrite.* FROM url_rewrite WHERE (request_path IN ('catalog/product/view/id/109340/category/8679', 'catalog/product/view/id/109340/category/8679/')) AND (store_id IN ('1')) - > []

    SELECT url_rewrite.*, relation.category_id, relation.product_id FROM url_rewrite LEFT JOIN catalog_url_rewrite_product_category AS relation ON url_rewrite.url_rewrite_id = relation.url_rewrite_id WHERE (url_rewrite.request_path IN ('catalog/product/view/id/109340/category/8679', 'catalog/product/view/id/109340/category/8679/')) AND (url_rewrite.store_id IN ('1')) AND (relation.category_id IS NULL) - > []

    SELECT url_rewrite.*, relation.category_id, relation.product_id FROM url_rewrite LEFT JOIN catalog_url_rewrite_product_category AS relation ON url_rewrite.url_rewrite_id = relation.url_rewrite_id WHERE (url_rewrite.entity_id IN ('109340')) AND (url_rewrite.entity_type IN ('product')) AND (url_rewrite.store_id IN (1)) AND (relation.category_id IS NULL) - > []

    SELECT url_rewrite.*, relation.category_id, relation.product_id FROM url_rewrite LEFT JOIN catalog_url_rewrite_product_category AS relation ON url_rewrite.url_rewrite_id = relation.url_rewrite_id WHERE (url_rewrite.entity_type IN ('product')) AND (url_rewrite.entity_id IN ('456', '3618', '5142', '5174', '5689', '5690', '17711', '21247', '24160', '38761', '38779', '38782', '42506', '49597', '106283', '111329', '113135')) AND (url_rewrite.store_id IN (1)) AND (url_rewrite.is_autogenerated IN (1)) AND (relation.category_id IS NULL) - > [] S

    opened by Genaker 0
  • Price Index / Price

    Price Index / Price

    SELECT catalogrule_product_price.product_id, catalogrule_product_price.rule_price FROM catalogrule_product_price WHERE (rule_date = '2021-10-12') AND (website_id = '1') AND (customer_group_id = 0) AND (product_id IN('25718'))

    Price Index SQL catalog_product_index_price ...

    SELECT e.*, price_index.price, price_index.tax_class_id, price_index.final_price, IF(price_index.tier_price IS NOT NULL, LEAST(price_index.min_price, price_index.tier_price), price_index.min_price) AS minimal_price, price_index.min_price, price_index.max_price, price_index.tier_price, cat_index.position AS cat_index_position, stock_status_index.stock_status AS is_salable, links.link_id, links.product_id AS _linked_to_product_id, link_attribute_position_int.value AS position FROM catalog_product_entity AS e INNER JOIN catalog_product_index_price AS price_index ON price_index.entity_id = e.entity_id AND price_index.customer_group_id = 0 AND price_index.website_id = '1' INNER JOIN catalog_category_product_index_store1 AS cat_index ON cat_index.product_id=e.entity_id AND cat_index.store_id=1 AND cat_index.visibility IN(2, 4) AND cat_index.category_id=2 LEFT JOIN cataloginventory_stock_status AS stock_status_index ON e.entity_id = stock_status_index.product_id AND stock_status_index.website_id = 0 AND stock_status_index.stock_id = 1 INNER JOIN catalog_product_link AS links ON links.linked_product_id = e.entity_id AND links.link_type_id = 1 LEFT JOIN catalog_product_link_attribute_int AS link_attribute_position_int ON link_attribute_position_int.link_id = links.link_id AND link_attribute_position_int.product_link_attribute_id = '1' INNER JOIN catalog_product_entity AS product_entity_table ON links.product_id = product_entity_table.row_id AND (product_entity_table.created_in <= '1630438980' AND product_entity_table.updated_in > '1630438980') WHERE ((e.entity_id NOT IN('109340')) AND (links.product_id in (81983)) AND (e.row_id != '81983')) AND (e.created_in <= '1630438980') AND (e.updated_in > '1630438980') ORDER BY e.entity_id ASC LIMIT 20

    Option Prices :

    SELECT main_table.*, default_option_title.title AS default_title, store_option_title.title AS store_title, IF(store_option_title.title IS NULL, default_option_title.title, store_option_title.title) AS title, default_option_price.price AS default_price, default_option_price.price_type AS default_price_type, store_option_price.price AS store_price, store_option_price.price_type AS store_price_type, IF(store_option_price.price IS NULL, default_option_price.price, store_option_price.price) AS price, IF(store_option_price.price_type IS NULL, default_option_price.price_type, store_option_price.price_type) AS price_type FROM catalog_product_option AS main_table INNER JOIN catalog_product_entity AS cpe ON cpe.row_id = main_table.product_id AND (cpe.created_in <= '1630438980' AND cpe.updated_in > '1630438980') INNER JOIN catalog_product_option_title AS default_option_title ON default_option_title.option_id = main_table.option_id LEFT JOIN catalog_product_option_title AS store_option_title ON store_option_title.option_id = main_table.option_id AND store_option_title.store_id = 1 LEFT JOIN catalog_product_option_price AS default_option_price ON default_option_price.option_id = main_table.option_id AND default_option_price.store_id = 0 LEFT JOIN catalog_product_option_price AS store_option_price ON store_option_price.option_id = main_table.option_id AND store_option_price.store_id = 1 WHERE (cpe.entity_id = '109340') AND (default_option_title.store_id = 0) ORDER BY sort_order ASC, title ASC - > []

    Tire customer Group Price:

    SELECT catalog_product_entity_tier_price.value_id AS price_id, catalog_product_entity_tier_price.website_id, catalog_product_entity_tier_price.all_groups, catalog_product_entity_tier_price.customer_group_id AS cust_group, catalog_product_entity_tier_price.value AS price, catalog_product_entity_tier_price.qty AS price_qty, catalog_product_entity_tier_price.percentage_value FROM catalog_product_entity_tier_price WHERE (website_id = 0) AND (row_id = '81983') ORDER BY qty ASC

    CAtalog rule Product Price:

    SELECT catalogrule_product_price.product_id, catalogrule_product_price.rule_price FROM catalogrule_product_price WHERE (rule_date = '2021-10-12') AND (website_id = '1') AND (customer_group_id = 0) AND (product_id IN('109340')) - > []

    opened by Genaker 0
  • Gallery SQL

    Gallery SQL

    SQL to select Gallery stuff for MAgento 2

    SELECT main.value_id, main.value AS file, main.media_type, entity.row_id, IFNULL(value.label, default_value.label) AS label, IFNULL(value.position, default_value.position) AS position, IFNULL(value.disabled, default_value.disabled) AS disabled, default_value.label AS label_default, default_value.position AS position_default, default_value.disabled AS disabled_default, IFNULL(value_video.provider, default_value_video.provider) AS video_provider, IFNULL(value_video.url, default_value_video.url) AS video_url, IFNULL(value_video.title, default_value_video.title) AS video_title, IFNULL(value_video.description, default_value_video.description) AS video_description, IFNULL(value_video.metadata, default_value_video.metadata) AS video_metadata, default_value_video.provider AS video_provider_default, default_value_video.url AS video_url_default, default_value_video.title AS video_title_default, default_value_video.description AS video_description_default, default_value_video.metadata AS video_metadata_default FROM catalog_product_entity_media_gallery AS main INNER JOIN catalog_product_entity_media_gallery_value_to_entity AS entity ON main.value_id = entity.value_id LEFT JOIN catalog_product_entity_media_gallery_value AS value ON main.value_id = value.value_id AND value.store_id = 1 AND value.row_id = entity.row_id LEFT JOIN catalog_product_entity_media_gallery_value AS default_value ON main.value_id = default_value.value_id AND default_value.store_id = 0 AND default_value.row_id = entity.row_id LEFT JOIN catalog_product_entity_media_gallery_value_video AS value_video ON value.value_id = value_video.value_id AND value.store_id = value_video.store_id LEFT JOIN catalog_product_entity_media_gallery_value_video AS default_value_video ON default_value.value_id = default_value_video.value_id AND default_value.store_id = default_value_video.store_id WHERE (main.attribute_id = '88') AND (main.disabled = 0) AND (entity.row_id = '81983') ORDER BY IF(value.position IS NULL, default_value.position, value.position)

    SELECT main.value_id, main.value AS file, main.media_type, entity.row_id, IFNULL(value.label, default_value.label) AS label, IFNULL(value.position, default_value.position) AS position, IFNULL(value.disabled, default_value.disabled) AS disabled, default_value.label AS label_default, default_value.position AS position_default, default_value.disabled AS disabled_default, IFNULL(value_video.provider, default_value_video.provider) AS video_provider, IFNULL(value_video.url, default_value_video.url) AS video_url, IFNULL(value_video.title, default_value_video.title) AS video_title, IFNULL(value_video.description, default_value_video.description) AS video_description, IFNULL(value_video.metadata, default_value_video.metadata) AS video_metadata, default_value_video.provider AS video_provider_default, default_value_video.url AS video_url_default, default_value_video.title AS video_title_default, default_value_video.description AS video_description_default, default_value_video.metadata AS video_metadata_default FROM catalog_product_entity_media_gallery AS main

      | INNER JOIN catalog_product_entity_media_gallery_value_to_entity AS entity ON main.value_id = entity.value_id   | LEFT JOIN catalog_product_entity_media_gallery_value AS value ON main.value_id = value.value_id AND value.store_id = 1 AND value.row_id = entity.row_id   | LEFT JOIN catalog_product_entity_media_gallery_value AS default_value ON main.value_id = default_value.value_id AND default_value.store_id = 0 AND default_value.row_id = entity.row_id   | LEFT JOIN catalog_product_entity_media_gallery_value_video AS value_video ON value.value_id = value_video.value_id AND value.store_id = value_video.store_id   | LEFT JOIN catalog_product_entity_media_gallery_value_video AS default_value_video ON default_value.value_id = default_value_video.value_id AND default_value.store_id = default_value_video.store_id WHERE (main.attribute_id = '88') AND (main.disabled = 0) AND (entity.row_id = '81983') ORDER BY IF(value.position IS NULL, default_value.position, value.position) ASC

    opened by Genaker 0
Releases(1.0.1)
Owner
Egor Shitikov
Egor Shitikov
Collection of classes you can use to standardize data formats in your Laravel application.

Laravel Formatters This package is a collection of classes you can use to standardize data formats in your Laravel application. It uses the Service Co

Michael Rubel 88 Dec 23, 2022
A package to filter laravel model based on query params or retrieved model collection

Laravel Filterable A package to filter laravel model based on query params or retrived model collection. Installation Require/Install the package usin

Touhidur Rahman 17 Jan 20, 2022
Allows Filament static assets (css, js) to be served directly from /public

Filament Static Asset Handling This package aims to solve improve the static asset handling of the amazing Laravel package Filament. By default Filame

Jamie Holly 8 Dec 6, 2022
A laravel package to handle sanitize process of model data to create/update model records.

Laravel Model UUID A simple package to sanitize model data to create/update table records. Installation Require the package using composer: composer r

null 66 Sep 19, 2022
Generate Data Transfer Objects directly from JSON objects

Json 2 DTO Spatie's Data Transfer Object library is awesome, but typing out DTOs can quickly become a chore. Inspired by Json2Typescript style tools,

null 111 Jan 3, 2023
Laravel-OvalFi helps you Set up, test, and manage your OvalFi integration directly in your Laravel App.

OvalFi Laravel Package Laravel-OvalFi helps you Set up, test, and manage your OvalFi integration directly in your Laravel App. Installation You can in

Paul Adams 2 Sep 8, 2022
This Laravel Nova tool lets you run artisan and bash commands directly from Nova 4 or higher.

Laravel Nova tool for running Artisan & Shell commands. This Nova tool lets you run artisan and bash commands directly from nova. This is an extended

Artem Stepanenko 17 Dec 15, 2022
The query filter bundle allows you to filter data from QueryBuilder and the Database.

The query filter bundle allows you to filter data from QueryBuilder and the Database. you can filter multiple columns at the same time and also you can filter relation fields with two-level deep and without any join in your query builder.

Bugloos 15 Dec 29, 2022
A collection of classes to be extended/used in laravel apps for quick development

laraquick A collection of classes to be extended/used in laravel applications for quick development. Introduction The library contains traits with wel

Ezra Obiwale 35 Dec 13, 2022
States allows you to create PHP classes following the State Pattern in PHP.

States allows you to create PHP classes following the State Pattern in PHP. This can be a cleaner way for an object to change its behavior at runtime without resorting to large monolithic conditional statements and this improve maintainability and workflows writing.

Teknoo Software 10 Nov 20, 2022
PHP components - collection of cross-project PHP classes

PHP components Collection of cross-project PHP classes. Install: $ composer require ansas/php-component Ansas\Component\Convert\ConvertPrice Convert "

null 1 Jan 5, 2022
A collection of common algorithms implemented in PHP. The collection is based on "Cracking the Coding Interview" by Gayle Laakmann McDowell

PHPAlgorithms A collection of common algorithms implemented in PHP. The collection is based on "Cracking the Coding Interview" by Gayle Laakmann McDow

Doğan Can Uçar 921 Dec 18, 2022
A laravel package to attach uuid to model classes

Laravel Model UUID A simple package to generate model uuid for laravel models Installation Require the package using composer: composer require touhid

null 10 Jan 20, 2022
The missing laravel helper that allows you to inspect your eloquent queries with it's bind parameters

Laravel Query Inspector The missing laravel helper that allows you to ispect your eloquent queries with it's bind parameters Motivations Let's say you

Mouad ZIANI 59 Sep 25, 2022
Package with small support traits and classes for the Laravel Eloquent models

Contains a set of traits for the eloquent model. In future can contain more set of classes/traits for the eloquent database.

Martin Kluska 3 Feb 10, 2022
A laravel package to generate model hashid based on model id column.

Laravel Model Hashid A package to generate model hash id from the model auto increment id for laravel models Installation Require the package using co

Touhidur Rahman 13 Jan 20, 2022
Laravel-model-mapper - Map your model attributes to class properties with ease.

Laravel Model-Property Mapper This package provides functionality to map your model attributes to local class properties with the same names. The pack

Michael Rubel 15 Oct 29, 2022
Laravel comments - This package enables to easily associate comments to any Eloquent model in your Laravel application

Laravel comments - This package enables to easily associate comments to any Eloquent model in your Laravel application

Rubik 4 May 12, 2022
This Laravel package merges staudenmeir/eloquent-param-limit-fix and staudenmeir/laravel-adjacency-list to allow them being used in the same model.

This Laravel package merges staudenmeir/eloquent-param-limit-fix and staudenmeir/laravel-adjacency-list to allow them being used in the same model.

Jonas Staudenmeir 5 Jan 6, 2023