magento2 – Creating a vendor panel in magento 2?

I am new to magento, and I have got a requirement from client.

Background of requirement : There are 10 vendors pincode based and 4 main vendors zone wise, linked with my client. The client wants to route the order based on the nearest pincode vendor. The vendor can accept or deny the order received. Once the vendor denies the order, the order then goes to the main vendor of that zone. I know how to create custom modules but I am not sure how to handle this request and from where to start ?

How can I achieve this functionality and what are the aspects I need to cover in the order fulfillment under this scenario. ? Below are the major requirements on frontend :

  1. The user enters pincode, it is checked from backend and deliverable vendors are listed along with their price list.

  2. Once user selects a vendor and places an order the order is routed to that vendor.

What all will be the tables I need to consider to create module to achieve this requirement. Is there any similar extension for this ? I tried searching for multi vendor module but that seems little different or can I use the same and extend it, can anyone guide me by giving some idea as I have just started learning this framework.

magento 1.9 – Get Parent SKU from ordered simple products

I want to show the review form to customer who bought the product. I get it solved with below mention code but it is not working for configurable product. How can I get parent associated product with this.

$cid = 0; if(Mage::getSingleton('customer/session')->isLoggedIn()) {
$customerData = Mage::getSingleton('customer/session')->getCustomer();
$cid = $customerData->getId();
}
$orderItems = Mage::getResourceModel('sales/order_item_collection')
->addFieldToFilter('sku', $this->getProductInfo()->getSku())
->toArray(array('order_id'));
$orderIds = array_unique(array_map(
function($orderItem) {
   return $orderItem('order_id');
},
$orderItems('items')));
$orderCollection = Mage::getResourceModel('sales/order_collection')
->addFieldToFilter('entity_id',   array('in'  => $orderIds))
->addFieldToFilter('customer_id', array('eq' => $cid));
$orderCollection->getSelect()->group('customer_id');
$customerCollection = Mage::getModel('customer/customer')->getCollection()
->addFieldToFilter('entity_id', array('in' => $orderCollection->getColumnValues('customer_id')));
foreach ($customerCollection as $customer) {
}

magento2 – Elastic Search (v7) changing Magento default product sort position in categories

Not the actual answer but you can identify some ways.

Add two plugins one is for GetLoadedProductCollection and second is for what ElasticSearch returning ids.

File: di.xml

<type name="MagentoCatalogBlockProductListProduct">
        <plugin name="VendorModule::logListProductQuery" type="VendorModulePluginCatalogProductPluginListProduct"/>
</type>

File : PluginListProduct.php

namespace VendorModulePluginCatalogProduct;
    
use PsrLogLoggerInterface;

class PluginListProduct
{
     
    public function __construct(
        LoggerInterface $logger
    )
    {
        $this->logger = $logger;

    }

     
    public function afterGetLoadedProductCollection(MageListProduct $subject, $result)
    {
        $writer = new ZendLogWriterStream(BP . '/var/log/PluginListProductQuery.log');
        $logger = new ZendLogLogger();
        $logger->addWriter($writer);
        
        $logger->info($result->getSelect()->__toString());      

        return $result;
    }
}

Also, add a custom plugin it will help you to identify which ids ElasticSearch returning.
This will only useful if ElasticSearch is using as Catalog Search engine.

File: di.xml

<type name="MagentoElasticsearchSearchAdapterResponseFactory">
        <plugin name="Vendor_Module::responseCheckFromElasticSearch"
                type="VendorModulePluginResponseCheck"
                disabled="false"/>
    </type>

File: ResponseCheck.php

<?php
namespace VendorModulePlugin;

use PsrLogLoggerInterface;


class ResponseCheck
{   
    protected $logger;
 
    public function __construct(
        LoggerInterface $logger
    )
    {
        $this->logger = $logger;

    }


    public function beforeCreate(MagentoElasticsearchSearchAdapterResponseFactory $subject, $result)
    {
        $docRaw = $docRawScore = array();
        $writer = new ZendLogWriterStream(BP . '/var/log/ElasticResponseCheck.log');
        $logger = new ZendLogLogger();
        $logger->addWriter($writer);
        if (!is_array($result) || empty($result)) return false;
        foreach ($result('documents') as $rawDocument) {
            $docRaw() = $rawDocument('_id');
            $docRawScore() = $rawDocument('_score');
            
        }

        $logger->info('ID: ' . implode(',', $docRaw));
        $logger->info('SCORE: ' . implode(',', $docRawScore));
        $logger->info('*************************************** END *********************************************');

    }


}

Probably you will get following order by in PluginListProductQuery.log and compare these ids with what is returning in ElasticResponseCheck.log

  • With ElasticSearch as a search engine
    possible order by for Elastic search would be – ORDER BY FIELD(e.entity_id,103,102,101)

  • With MySQL as a search engine
    possible order by – ORDER BY cat_index.position asc, e.entity_id DESC LIMIT 4

Hope this helps.

php code to generate sku in magento 1.9.3

As you didn’t provide either your module code or the code that you’ve tried to generate the sku, i can provide you with a few ways how you could generate a SKU for the new products that you import through your Mass product Update Module.

  1. Create a custom module and observe either of these events

catalog_product_save_before or catalog_product_attribute_update_before

there are also other events like, which you can try and use the one suits your requirements.

catalog_product_save_after

catalog_product_save_commit_after

catalog_product_attribute_update_after
  1. Get the product(s) data from the Event Observer Model that you should create

  2. Check whether its a new product

  3. In case of new products, generate a SKU and then set the SKU and save the product.

Hope this helps !

Also read these Magento SE threads below to get the proper understanding of these events and Magento ORM

How can I differentiate between product creation and saving existing products?

https://magento.stackexchange.com/questions/120004/difference-between-catalog-product-save-after-and-catalog-product-save-commit-af

How prevent a model data save using _save_before event

Will $product->save() trigger catalog_product_save_after?

catalog_product_save_after Event for Massaction


BTW if you want to get help from others on this platform, you need to provide the code that you’ve tried.

magento2.4 – media css not reflect in mobile magento 2

I am making responsive design for mobile view. I have installed Porto Magento 2 theme. Porto theme provides css file custom design changes. I have made custom changes in custom.css file.
Porto theme put custom.css file in following path. Magento 2 hosted on nginx server.

/pub/media/porto/web/css/custom.css

and custom.css file imported via below code in app/design/frontend/Smartwave/Porto/Smartwave_Porto/templates/html/head.phtml

<link rel="stylesheet" type="text/css" media="all" href="<?php echo $_helper->getPortoWebDir().'css/custom.css'; ?>">

Now the problem is if I do changes in custom.css its not refecting in my mobile. It just reflect on my PC in responsive view(sometimes I have to do hard refresh on PC to check made chages). When I checked in my mobile it’s not reflect changes made in custom.css file.

Below operation I did to show reflected css changes,but no luck

I clear and flush cache

I disabled the cache and checked in my mobile but still show old changes.

I ran php bin/magento setup:static-content:deploy -f

I run index command but still in my mobile showing old css changes.

Currectly, Magento website mode is developer.

cleared generated folder

Why its not reflect on the custom.css
I have an doubt. This custom.css located in /pub/media/porto/web/css/custom.css path is correct according magento 2 standard ?

Please Give me solution.I am tired of this situation.