Skip to main content

Magento usefull codes

Get order items inside the order

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
        $order = $objectManager->create('Magento\Sales\Model\Order')->load($block->getRequest()->getParam("order_id"));
        $easyParcelData['shipping_address'] = array(
            'id'            => $order->getIncrementId(),
            'status'        => $order->getStatus(),
            'name'          => $order->getCustomerName(),
            'email'         => $order->getCustomerEmail(),
            'telephone'     => $order->getShippingAddress()->getTelephone(),
            'street'        => $order->getShippingAddress()->getStreet(),
            'postcode'       => $order->getShippingAddress()->getPostcode(),
            'city'          => $order->getShippingAddress()->getCity(),
            'state'          => $order->getShippingAddress()->getState(),
            'country'       => $order->getShippingAddress()->getCountryId(),
            'weight'        => $order->getWeight(),
        );
foreach ($orderCollection as $order) {
  $items=array();
  foreach ($order->getAllItems() as $item) {
        $items[] = array(
            'id'            => $order->getIncrementId(),
            'name'          => $item->getName(),
            'sku'           => $item->getSku(),
            'Price'         => $item->getPrice(),
            'Ordered Qty'   => $item->getQtyOrdered(),
        );
    }
    $orders['orders'][] = array(
        'id'            => $order->getIncrementId(),
        'store'         => 'magento',
        'status'        => $order->getStatus(),
        'name'          => $order->getCustomerName(),
        'email'         => $order->getCustomerEmail(),
        'telephone'     => $order->getShippingAddress()->getTelephone(),
        'street'        => $order->getShippingAddress()->getStreet(),
        'pincode'       => $order->getShippingAddress()->getPostcode(),
        'city'          => $order->getShippingAddress()->getCity(),
        'weight'        => $order->getWeight(),
        'items'        => $items,
    );
}

php bin/magento cache:clean
php bin/magento cache:flush
php bin/magento indexer:reindex
php bin/magento setup:upgrade
php bin/magento setup:static-content:deploy -f

php bin/magento deploy:mode:set developer
DB username/password = magento_admin/magento-admin

?templatehints=magento
templatehints=magento

https://magento2tutorial.magestore.com/magento-2-theme-create-sample-custome-theme/

/vendor/magento/framework/View/Element/Template/File/Validator.php In
$realPath = $this->fileDriver->getRealPath($path);
$realPath = str_replace('\\', '/', $this->fileDriver->getRealPath($path));

php bin/magento module:status
php bin/magento module:enable Namespace_ModuleName



block class="Webkul\HelloWorld\Block\HomePage" template="Webkul_HelloWorld::homepage.phtml"

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$product = $objectManager->get('Magento\Catalog\Model\Product')->load($product_id);

Comments

Popular posts from this blog

Laravel Request Validator json response example

 Step 1 :  php artisan make : request  StoreArticleRequest Step 2 : <?php namespace App\Http\Requests; use Illuminate\Foundation\Http\FormRequest; use Illuminate\Http\JsonResponse; use Illuminate\Contracts\Validation\Validator; use Illuminate\Http\Exceptions\HttpResponseException; class StoreArticleRequest extends FormRequest { /** * Determine if the user is authorized to make this request. * * @return bool */ public function authorize () { return true ; } /** * Get the validation rules that apply to the request. * * @return array */ public function rules () { return [ 'title' => 'required' ]; } protected function failedValidation (Validator $validator ) { if ($this -> wantsJson () || $this -> ajax ()) { throw new HttpResponseException( response () -> json ([ 'status' => ...

Bad words or Swear words filter Jquery

Bad words or Swear words filter Jquery var blacklist = /\b(4r5e|5h1t|5hit|a55|anal|anus|ar5e|arrse|arse|ass|ass-fucker|asses|assfucker|assfukka|asshole|assholes|asswhole|a_s_s|b!tch|b00bs|b17ch|b1tch|ballbag|balls|ballsack|bastard|beastial|beastiality|bellend|bestial|bestiality|bi+ch|biatch|bitch|bitcher|bitchers|bitches|bitchin|bitching|bloody|blow job|blowjob|blowjobs|boiolas|bollock|bollok|boner|boob|boobs|booobs|boooobs|booooobs|booooooobs|breasts|buceta|bugger|bum|bunny fucker|butt|butthole|buttmuch|buttplug|c0ck|c0cksucker|carpet muncher|cawk|chink|cipa|cl1t|clit|clitoris|clits|cnut|cock|cock-sucker|cockface|cockhead|cockmunch|cockmuncher|cocks|cocksuck|cocksucked|cocksucker|cocksucking|cocksucks|cocksuka|cocksukka|cok|cokmuncher|coksucka|coon|cox|crap|cum|cummer|cumming|cums|cumshot|cunilingus|cunillingus|cunnilingus|cunt|cuntlick|cuntlicker|cuntlicking|cunts|cyalis|cyberfuc|cyberfuck|cyberfucked|cyberfucker|cyberfuckers|cyberfucking|d1ck|damn|dick|dickhead|dildo|dildos|dink|din...