PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0
Showing posts with label magento-2.0. Show all posts
Showing posts with label magento-2.0. Show all posts

Wednesday, December 7, 2022

[FIXED] How to use Magento 2 with an openlitespeed (free) web server?

 December 07, 2022     .htaccess, litespeed, magento-2.0, magento-2.3, magento2     No comments   

Issue

I'm trying to setup Magento 2.3.0 server with OpenLiteServer and keep on bumping weird Rewrite rule errors:

LiteSpeed errors

Here's the full list of errors.

The website is working, but CSS and JS cannot be loaded so there are lot's of 404s

tyanabelle.com

I'm thinking that I may be doing something wrong, or that OpenLiteSpeed does not support all of those commands inside the .htaccess files.

The magento 2 installation is just a basic magento 2.3.0 composer installation without anything added to it, and thus is set to default mode.

The file permissions are looking good too, but note that files are missing from the pub/static/frontend/luma/en_US/ directory:

permissions

Any hints?

Thank you


Solution

Assuming that the website is under /magento2 you'll need to insert the rewrites on the virtual host, at the rewrites section, enable the rewrite module as well.

  RewriteRule ^/magento2/pub/static/version.+?/(.+)$ /magento2/pub/static/$1 [L]
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-l
  RewriteRule /magento2/pub/static/.* /magento2/pub/static.php?resource=$0 [L]
  RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
  RewriteCond %{REQUEST_METHOD} ^TRAC[EK]
  RewriteRule .* - [L,R=405]
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME} !-l
  RewriteRule .* /magento2/index.php [L]


Answered By - user7678643
Answer Checked By - Clifford M. (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Tuesday, August 23, 2022

[FIXED] How to add/Insert Extension in magento 2.0?

 August 23, 2022     magento, magento-2.0, magento2, zend-framework     No comments   

Issue

I tried to add the external magento-2 extension but I can't add it because I can't find magento-connect in admin side. I think the admin panel doesn't have magento-connect. Do you have any idea about this to share, or a good tutorial that could help?


Solution

Installing Magento 2 extension is an easy task .. you just need to extract your extension zip file and place the folder inside your Magento 2 app/code directory so that the structure should be like app/code/namespace/module-name

then you have to run some commands for registering your Magento 2 extension

open terminal inside your Magento 2 directory, parallel to the app directory

run these commands-

  1. giving read write permission to your magento 2 directory

    sudo chmod -R 777 /path of Magento 2 folder such as /opt/lampp/htdocs/Training/Magento_2.0

if you are using linux operating system then you have to run this command . for windows it is not necessary.

  1. for registering your extension

    /opt/lampp/bin/php bin/magento module:enable Namespace_Modulename /opt/lampp/bin/php bin/magento setup:upgrade

  2. for compiling your extension code

    /opt/lampp/bin/php bin/magento setup:di:compile

now flush your cache , delete cache folder from your Magento 2 var directory.



Answered By - CedCommerce
Answer Checked By - Dawn Plyler (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

[FIXED] How to remove "My Wish List" and "Compare Products" blocks from Magento 2.0 Luma template?

 August 23, 2022     magento-2.0, magento2     No comments   

Issue

I have spent a lot of hours trying to remove "My Wish List" and "Compare Products" blocks from Luma template. Besides, I need to change and remove some of the bottom links.

I cannot find where to modify. Can you help me, please?

Thanks


Solution

I've tried following step it worked for me.

1. My Wish List

For wish List you need to remove it via Admin > Stores > Configuration > Customers > Wish list > General Options make to enabled to no and then save it.

2. Compare Product

Here you need to do some coding level changes. follow me

Go to vendor > magento > theme-frontend-luma > Magento_Catalog > layout > default.xml

Open this file find this tag "" and before body end tag put the following code

<referenceBlock name="catalog.compare.sidebar" remove="true"/>

Make sure this will remove compare product from category product listing however you can uses this to any layout.

Once you done with this don't forget to clearing cache if enable otherwise you will not get desirable output.

Let me know if you have still any query



Answered By - samumaretiya
Answer Checked By - Cary Denson (PHPFixing Admin)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Monday, August 22, 2022

[FIXED] How to get current category in magento2?

 August 22, 2022     magento-2.0, magento2     No comments   

Issue

How can i get current category in magento2 ?

I want to get category name and category id in custom phtml file.


Solution

Try this code. this will definitely help you.

<?php 
    $objectManager = \Magento\Framework\App\ObjectManager::getInstance();
    $category = $objectManager->get('Magento\Framework\Registry')->registry('current_category');//get current category
    echo $category->getId();
    echo $category->getName();
?>


Answered By - Makwana Ketan
Answer Checked By - David Marino (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Tuesday, May 17, 2022

[FIXED] How to get Product Attribute Options by attribute code in Magento 2.0

 May 17, 2022     magento-2.0, php     No comments   

Issue

I am trying to retrieve the list of dropdown attributes and check if the value exists (if it does i need to get the value and assign it to the product) and if it doesnt i will have to create it and get its value to assign it to the product.

$attribute = $this->objectManager->create('Magento\Eav\Model\Entity\Attribute');
$attributeId = $attribute->getIdByCode('catalog_product','manufacturer');
$model = $this->objectManager->create('Magento\Catalog\Model\ResourceModel\Eav\Attribute');
$model->load($attributeId);
print_r($model->getFrontendLabel());

Solution

Following Magento 2 guidelines, you should not use ObjectManager by yourself. Instead, you must use dependency injection. More info here

In your Block/Controller/Helper..., create a constructor and inject \Magento\Catalog\Api\ProductAttributeRepositoryInterface class. For example :

private \Magento\Catalog\Api\ProductAttributeRepositoryInterface $productAttributeRepository;

public function __construct(
    \Magento\Catalog\Api\ProductAttributeRepositoryInterface $productAttributeRepository
) {
    $this->productAttributeRepository = $productAttributeRepository;
}

Then, in your dedicated method, you want to call (PHPDoc added for clarity) :

/** @var \Magento\Eav\Api\Data\AttributeOptionInterface[] $manufacturerOptions */
$manufacturerOptions = $this->productAttributeRepository->get('manufacturer')->getOptions();

You can now get options values and labels this way :

foreach ($manufacturerOptions as $manufacturerOption) {
    $manufacturerOption->getValue();  // Value
    $manufacturerOption->getLabel();  // Label
}


Answered By - Yonn Trimoreau
Answer Checked By - Willingham (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Older Posts Home
View mobile version

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
All Comments
Atom
All Comments

Copyright © PHPFixing