ORA-00928: missing SELECT keyword Laravel

First of all a great thanks to the contributors of Oracle Database Driver package https://github.com/yajra/laravel-oci8 for Laravel and making life easy for the developers who are developing applications on top of Laravel as framework and Oracle DB as the persistence layer.

The error 'ORA-00928: missing SELECT keyword' is possibly a result of the following scenarios.
1) You may be using resource controller and creating records using the 'create' method on model, i.e. Model::create.
2) You have already generated sequence number and passing it as a value to insert in the record.

To resolve the annoying error 'ORA-00928: missing SELECT keyword' while using Laravel with the Oracle Database Driver package, change the create method to insert, i.e. Model::insert($data);.


How to Get Current DateTime of Store

The current date and time according to the timezone of store can be found using below code snippet.

In your class file inject instance of 'Timezone' as below.

protected $_timezone;
public function __construct(
    ....
    \Magento\Framework\Stdlib\DateTime\TimezoneInterface $timezone,
    ....
) {
    ....
    $this->_timezone = $timezone;
    ....
}


Now, in your method, you can find the current date and time of store using below statement.
$this->_timezone->date()->format('Y-m-d H:i:s');
 

Incorrect dependency in class already exists in context object

Magento 2 classes have dependency injection in constructor method. One special object which is there is context.

The context object further provides many other objects. Apparently, if you have injected context object in your module's class which may further inheriting some Magento 2 class, you may not need to inject some objects which are already being provided by context object. This mechanism makes sure, your system does not end up with many duplicate objects occupying memory and leads to poor performance.

When your Magento 2 shop runs with developer mode, the system does not report any issue. But when you switch the mode to production, it reports the error.
Also, when you run php bin/magento setup:di:compile command, the system reports the error.

Now, to the point, how to solve the error which looks like something below, the class name may be different.
Errors during compilation:
Helper\Data
Incorrect dependency in class Helper\Data in vendor/xxx/Helper/Data.php
\Magento\Framework\SOME\CLASS already exists in context object

Total Errors Count: x.

As we have learned above, the object is already being provided by the context object. So, it does not need to be injected, instead retrieved from context object.
Step 1: Remove the object from your constructor which was reported as already exists.
Step 2: Assign your class property by retrieving the object from context object.
For example, if your constructor method looks like below and reported error for class ScopeConfigInterface.

    public function __construct(
        \Magento\Framework\App\Helper\Context $context,
        \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
    ) {
        $this->_scopeConfig = $scopeConfig;
        
        parent::__construct($context);

    }

The rectification will look like below.

      public function __construct(
        \Magento\Framework\App\Helper\Context $context
    ) {
        $this->_scopeConfig = $context->getScopeConfig();
        
        parent::__construct($context);

    }

Hope, this will help you to rectify the error appeared while running php bin/magento setup:di:compile command.
Errors during compilation:
Incorrect dependency in class x.php
some class already exists in context object
Total Errors Count: x

Visit for affordable Magento 2 extensions which provides the most sought features only.

Sort By Ratings on Product Listing of Magento

Ever wondered what does your customers do to find the best and product from your catalog containing hundreds or thousands of products. 
Well, as a customer purchasing online rely more on the recommendations of other customers. 
Magento provides reviews and ratings module out of the box. Your customers can leave reviews and ratings for the products based on different criteria. These reviews can be useful to you for making the product as per the customer's expectations.
But, by publishing the reviews and ratings also helps the other customers  also to decide the purchase. When there are multiple similar kind of products in your catalog, the ratings will be even more important and useful for the customers.
Magento provides flexibility to sort the products by different attributes, however, sorting by ratings is missing.
Along with full use of review and ratings module, you should consider providing sorting by ratings and rich snippets of reviews.

If you are running your store on the Magento version 1, following product sorting extension for Magento 1 can be useful which is affordable from price point of view.
For the merchants who are running their store on Magento 2 platform, the product sorting extension is available here.