texts: is there a way to check if some code in Magento 2 is performed by a web API call

texts:
I am update a product stock item using the Magento API: <magento_url>/rest/V1/products/<sku>/stockItems/<item_id>
and I have now setup a plugin to override the default Magento behaviour. However, I'd like this behaviour to only be changed when the API code is called.
In other words, if I change the stock from the backend, I'd like my plugin to be ignored. thanks for your comments


texts:
I was reading on the new Pipeline deployment here but I don't understand how this is supposed to work in a repository.

In developer mode static content is dynamic, but if the build system commits it then it won't work anymore after the first time.

Also if the build system pulls changes, generates and then commits the repository will be a mess where every second commit is a "generate static content". I am probably missing something.


texts: Paypal graphics not loading on step '4. Payment Information' during checkout

texts:
Magento 1.9.4
Porto theme
Paypal Payments Pro

I've installed a fresh install of Magento 1.9.4. There have been no changes made to the system other than:

installed Porto theme
added calendar
disabled Form Key Validation on check-out

When going to step 4. Payment Information during checkout - the graphics that show for the Paypal payment options do NOT load. Instead it shows the graphic you get when system cannot load an image and it says: "Acceptance Mark". Why is this and how can it be fixed? We have Paypal Payments Pro. I tried deleting Cache and re-indexing but it did not help.


texts: Is it possible to install Page Builder in a previous version of Magento Commerce ( < 2.3)?

texts:
We'd like to know if it's possible to integrate the page builder extension (build in Magento Commerce 2.3) to a 2.2.5.

Did someone already try it, and faced a challenge ?

Is it worth it if the upgrade to 2.3 is planned > 7 months ?


texts: Magento 2: Type Error occurred when creating object

texts:
I had created a custom API for adding new customer in Magento 2.3. I had injected dependency injection and passed the method to create the customer account. But it gives me below error:

  main.CRITICAL: Type Error occurred when creating object: MyModule\Customapi\Model\Addcustomer, Too few arguments to function MyModule\Customapi\Model\Addcustomer::__construct(), 7 passed in /var/www/html/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php on line 116 and exactly 8 expected [] []

I had injected CustomerRepositoryInterface to add new customer like this:

<?php
namespace MyModule\Customapi\Model;
use MyModule\Customapi\Api\AddCustomerInterface;
use Magento\Store\Model\StoreManagerInterface;
use Magento\Customer\Api\AccountManagementInterface;

class AddCustomer implements AddCustomerInterface
{
    protected $request;
    protected $storeManager;
    protected $dataHelper;
    protected $accountManagementInterface;
    protected $authentication;
    private $accountConfirmation;
    protected $objectManager;
    protected $customerRepository;
    protected $_customerFactory;
    protected $_customerInterfaceFactory;

    public function __construct(
        StoreManagerInterface $storeManager,
        Data $dataHelper,
        RequestInterface $request,
        AccountConfirmation $accountConfirmation = null,
        AccountManagementInterface $accountManagementInterface,
        CustomerRepositoryInterface $customerRepository,
        \Magento\Customer\Model\Customer $customerFactory,
        \Magento\Customer\Api\Data\CustomerInterfaceFactory $customerInterfaceFactory
    ) {
        $objectManager = ObjectManager::getInstance();
        $this->storeManager = $storeManager;
        $this->dataHelper =$dataHelper;
        $this->request = $request;
        $this->accountManagementInterface = $accountManagementInterface;
        $this->accountConfirmation = $accountConfirmation ?: $objectManager
            ->get(AccountConfirmation::class);
        $this->customerRepository = $customerRepository;
        $this->_customerFactory = $customerFactory;
        $this->_customerInterfaceFactory = $customerInterfaceFactory;
    }

    public function addcustomer()
    {
        ...
        $customer = $this->_customerInterfaceFactory->create();
        ...
    }
}


texts: How to create root category programmatically in Magento 2?

texts:
I've found the topic of how to create root category in magento 2, but only form Admin Panel. I've found how to create SUBcategories programmatically in Magento 2 magento 2 create categories programmatically . I've found how to do it in Magento 1.x Create Root Category in magento programatically

But how to create a root category in Magento 2??


texts: Custom admin-grid multiselect preselect saved values

texts:
I have a custom backend-grid for some shipping-methods and I have the following problem:

Everytime I want to edit one of my grid-entries, the country-multi-select is resetted to blank. I´ve been trying a lot to get the previously saved values as preselected values in this multiselect, but I was not successful.

*_Edit_Form.php _prepareForm() excerpt:

$fieldset_rules->addField('allowedcountries', 'multiselect', array(
            'label'     => Mage::helper('kortwotze_shippingmadesimple')->__('Available Countries'),
            'class'     => 'required-entry',
            'required'  => true,
            'name'      => 'allowedcountries[]',
            'values'    => $countryList,
            'value'     => $model->getAllowedCountries(), // Not sure, what exactly to return...
            'note'      => Mage::helper('kortwotze_shippingmadesimple')->__('Mark the countries, for which this shipping method applies.'),
        ));

I have the suspicion, that my models have to return a distinct format of that data I want to use, but I have no clue. It may be important, that I serialize the selection while saving and save it as serialized string into a TEXT database-column.

Any help appreciated! I would love to give out more information if needed, but honestly: I am not sure, what I have to provide :D

Additional Info to oleksii.svarychevskyi:

$countryList looks like

2014-02-03T12:52:48+00:00 DEBUG (7): Array
(
    [0] => Array
        (
            [value] =>
            [label] => 1
        )

    [1] => Array
        (
            [value] => AF
            [label] => Afghanistan
        )

    [2] => Array
        (
            [value] => AX
            [label] => Alandinseln
        )

    [3] => Array
        (
            [value] => AL
            [label] => Albanien
        )

I tried with 'value' => array('DE') // Uppercase/Lowercase - no success. :/
I also tried with 'value' => 'DE' which also turned out not successful.

Solution

I was really stupid, thinking to save arrays from multiselects on my own. I tried to reinvent the wheel and build something shaped like a parrot.

Just use 'type' => 'multiselect' in your Grid/Edit and add something like this to your saveAction()

            foreach ($data as $key => $value) {
                if (is_array($value)) {
                    $data[$key] = $data[$key] = implode(',',$this->getRequest()->getParam($key));
                }
            }

(shamelessly stolen from https://stackoverflow.com/questions/14056140/magento-saving-multiselect-array-on-custom-model - thanks for that solution as well! )


texts: Catalog Price Rules applied to special_price

texts:
Currently magento is using the special price if its lower than the applied catalog price rule.

=> If the catalog price rule makes the product cheaper than the special price, then the catalog price rule defines the shop price.

But i need like this.

make catalog price rules be applied to the special price

i am using magento 1.8

And i have tried with https://stackoverflow.com/questions/18120342/catalog-price-rules-applied-to-special-price

but its not working for me.


texts: Possible Bug - Hidden tax amount on quote and order item but no discount amount

texts:
I came accross a problem with one of our customers order on magento 1.7.0.2. There seems to be two problems.

In backend there 5 items. 3 of the items has discount applied on them. 2 items do not have any discount applied on them + they both have exactly the same prices. But one of the items Row Total is not correct (it has some additional amount). But at the same time Grand Total is correct (Grand total is ignoring the extra amount on row total for this item)
After debugging i found in the database for this items both quote item and order item tables has hidden_tax_amount set.

To me this seems like a bug. From my understanding hidden_tax_amount cannot be applied on the itemsif there is no discount applied to the item. Second somehow even magento thinks it is wrong that is why not calculating this hidden_tax_ammount in Grand Total. Any thoughts will be appreciated.


texts: FAQ Page in Multiple store is shown only in one store

texts:
I'm using Mage World EasyFAQ extension and I want to display the same FAQ page on multiple stores.

In CMS > Manage Page I have created a page. With the URL Key "faq", and linked multiple stores to that page.

In the WYSIWYG editor I have added this line:

{{block type="faq/faq" name="faq.list" template="faq/faq.phtml" }}

It works only on one store. It creates the questions and answers.
But, on the other stores, it doesn't create the questions and answers.

I checked the HTML output through Firebug.
On the working page it shows that in

On some stores these div's with mw_faq classes aren't added.

Can you point me in the right direction in solving this problem?


texts:
I'm getting this error message when I open a product from admin -

  Fatal error: Class 'Varien_Data_Form_Element_Videos' not found in /home/firstgea/public_html/lib/Varien/Data/Form/Abstract.php on line 146

History:  I used a 1.8 database and a clean install of Magento 1.9.1. So I think it's a video plugin but I don't know how to get rid of it.


texts:
I have the following Magento code :

protected function _sendUploadResponse($fileName, $content, $contentType='application/octet-stream')
{
    $response = $this->getResponse();
    $response->setHeader('HTTP/1.1 200 OK','');
    $response->setHeader('Pragma', 'public', true);
    $response->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true);
    $response->setHeader('Content-Disposition', 'attachment; filename='.$fileName);
    $response->setHeader('Last-Modified', date('r'));
    $response->setHeader('Accept-Ranges', 'bytes');
    $response->setHeader('Content-Length', strlen($content));
    $response->setHeader('Content-type', $contentType);
    $response->setBody($content);
    $response->sendResponse();
    die;
}

when I try to validate my code I have this error: Use of die language construct is discouraged.

What I can do or what is the best way to replace the die function.


texts: We have updated our source images and need to reimport them into Magento. Does anyone know how to force uRapidFlow to import all images?


texts:
I added Simple Products in Magento 2.0.7 version and configured them properly like their quantity, price etc but on frontend, products are showing out of stock. I set their quantity 50, price accordingly and mark them as in stock but they are showing out of stock on the frontend.

Can anyone suggest me what i am missing?


texts: modify list.phtml to show only a limited number of products on home page

texts:
On the home page, I am trying to display70 only 6 random products on one row, from a category (id 24) that has 70 products. And randomly changed each time the page gets re-loaded.

The only method that works so far is from the following link
http://www.magikcommerce.com/blog/random-products-magento-home-page/
and using
{{block type="catalog/product_list" category_id="24" num_products="6" template="catalog/random.phtml"}} in home CMS.
Problem is that this is not responsive.

So I have been trying to use the rwd/default/template/catalog/product/list.phtml
with  the following code in home cms without success.
 {{block type="catalog/product_list_random" category_id="24" num_products="6" column_Count ="6" template="catalog/product/list.phtml"}}

With the above in home cms
1) it does not display products from id 24.
2) Second I can't control the the number of products it displays.
3) I can't find block type="catalog/product_list_random" any where. Is that a file?

ps. using rwd template files


texts:
I want to fire my custom ajax request when admin click on submit order button.

What I need to do for this ?


texts: Get Identifire of CMS Page if it is not active

texts:
How to Get Identifier of CMS Page if it is not active.
Using CMS Page Collection.


texts: Display "Page x of x" in toolbar: category pages and search results

texts:
I'm looking for a way to display "page x of x" in the toolbar portion of category and search results pages. When the products exceed the amount specified in the "results per page" filter, an ordered list of numbers is rendered, displaying the number of pages in product results. I need to display page numbers, not number of products.

This template is rendered from /templates/page/html/pager.phtml.

Can't find any info on this, have looked all over Google, Magento and StackExchange.


texts: 404 Not Found after fresh Magento 2.4.2 installation

texts:
I have never had any issues with fresh install of magento before 2.4.1.
I have a new Linux VM machine (Ubuntu server 18.04).

Installed PHP 7.4 , Apache and Mysql from this link Installation of
PHP, MYSQL and APACHE

Installed Composer

Installed Elastic search

Created composer project using this command composer create-project --repository-url=https://repo.magento.com/ magento/project-enterprise-edition=2.3.2-p1 <install-directory-name>

Added sample data using php bin\magento sampledata:deploy

Installed magento using following command
php bin/magento setup:install --base-url=http://localhost/me242 --backend-frontname=admin --db-host=localhost --db-name=me242 --db-user=root --db-password='dbpas' --admin-firstname=firstname  --admin-lastname=lastname --admin-email=fn@ln.com --admin-user=user --admin-password='passs!' --language=en_US --currency=USD --timezone=America/Los_Angeles --use-rewrites=1 --search-engine=elasticsearch7 --elasticsearch-host=localhost --elasticsearch-port=9200

This has worked for me fine up until 2.4.1. I am trying all possible ways to get it up and running 2.4.2 version but getting 404 error right away. The requested URL was not found on this server.
Can someone help me troubleshoot this in right direction.
Edit 1: I did not upgrade from 2.4.1 to 2.4.2. it was a fresh install.


texts: all product page showing 404 and i could not access admin pages magento 2

texts:
I have copied my Magento 2 backup to my new server

now I am getting

  all product page showing 404 and I could not access admin pages magento 2

exception.log

  main.CRITICAL: Unique constraint violation found
  {"exception":"[object]
  (Magento\Framework\Exception\AlreadyExistsException(code: 0):
  Unique constraint violation found at
  /public_html/vendor/magento/framework/Model/ResourceModel/Db/AbstractDb.php:425,
  Magento\Framework\DB\Adapter\DuplicateException(code: 1062):
  SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry
  '0' for key 'PRIMARY', query was: INSERT INTO mg_report_event
  (logged_at, event_type_id, object_id, subtype, store_id)
  VALUES ('2019-08-14 07:24:45', ?, ?, ?, ?) at
  public_html/vendor/magento/framework/DB/Adapter/Pdo/Mysql.php:580,
  Zend_Db_Statement_Exception(code: 23000): SQLSTATE[23000]: Integrity
  constraint violation: 1062 Duplicate entry '0' for key 'PRIMARY',
  query was: INSERT INTO mg_report_event (logged_at,
  event_type_id, object_id, subtype, store_id) VALUES
  ('2019-08-14 07:24:45', ?, ?, ?, ?) at
  public_html/vendor/magento/zendframework1/library/Zend/Db/Statement/Pdo.php:235,
  PDOException(code: 23000): SQLSTATE[23000]: Integrity constraint
  violation: 1062 Duplicate entry '0' for key 'PRIMARY' at
  /vendor/magento/zendframework1/library/Zend/Db/Statement/Pdo.php:228)"}
  []

I have tried this answer but not working

https://stackoverflow.com/a/49789752

Does anyone know how to solve this??


texts: Magento 2.2.4 Show error message returned by plugin

texts:
I'm beginner to Magento2 and I want to validate pincode which exists in custom table or not on Checkout page (www.test.com/checkout/), according to that I want to display error message on same page. Following is sample code of my plugin:

public function beforeSaveAddressInformation(
    \Magento\Checkout\Model\ShippingInformationManagement $subject,
    $cartId,
    \Magento\Checkout\Api\Data\ShippingInformationInterface $addressInformation
) {
    $shippingAddress = $addressInformation->getShippingAddress();
    $pincode = $shippingAddress->getPostcode();

    $enable = $this->helper->getIsEnable();
    $checkAddToCart = $this->helper->getIsCheckonAddtoCart();

    if ($enable && $checkAddToCart && $pincode) {
        $pincodeStatus = $this->helper->getPincodeStatus($pincode);

        if(!$pincodeStatus) {
            // Following error message want to show on checkout page
            throw new InputException(__($this->helper->getFailMessage()));
            exit;
        }
    }
}

Can anyone let me know is there any way to display standard error message thrown through plugin using Magento2 Standards. Or else I have to use custom jquery validation rule on Checkout page? if I have to use custom jquery validation rule, then let me know how can I apply jquery validation rule on Checkout page, please elaborate in brief.

Thanks in advance!


texts:
I think core_url_rewrite is built in the wrong way:

why it contains records for not visible products ( all simple associated to the configurable for example )
why it contains records for every storeview even if the request_path (url_key/url_path) for a product/category is the same for every storesview ?

I actually have 394415 records on this table ( my store has 28120 products and 7 storeviews ), if I could solve the above 2 point I think the table would be 10 times smaller.

Anybody worked on this before ?


texts: Trive revo ajax add to cart not working in magento2.1.3

texts:
I am installing Trive revo ajax add to cart plugin in my products, but its not working. It is free Extension.

There is no issue on console or anyfile. When I am clicking the add cart button, the button is changed to adding...

Afterthat, there is no response. Please help me anyone.


texts: Layered Navigation (different attributes)

texts:
Help me please.
I am trying to figure out why my left sidebar layered navigation just shows two attribute colors instead of three.

For example: I have 2 products
Product1 black and orange,
Product2 black and blue.

But, the color filter shows only blue and orange options.

Why is the black not appearing in the layered navigation options?


texts: Magento 2 How to load product collection, Category collection, Load product by id and get category by product id

texts:
I do have experience with magento 1 and in magento 1 i do know how to load the product collection, category collection, quote and product load by id.

Magento 2 is really new concept for me and syntax is completely changed in it. Need help how can i load Product collection, category collection, quote and product by id using magento 2 standard methods.

Magento 1 Product Collection:

 $productCollection = Mage::getModel('catalog/product')->getCollection();

How to call product collection in magento 2.

Magento 1 Category Collection:

$categoryCollection = Mage::getModel('catalog/category')->getCollection();

How to call category collection in magento 2

Magento 1 Load product by id :

$product = Mage::getModel('catalog/product')->load($id);

How to load in magento 2

Magento 1 load category by product id:

    $product = Mage::getModel('catalog/product')->load($_item['product_id']);
    $cats = $product->getCategoryIds();

How to load in magento 2?


texts:
I was trying to redirect the page after successful transition to custom page "Thank You".

  We have 2 methods. Paypal & Vica / Master Card.

In Paypal there is an option to set redirect page after successful transition.

Profile -> Website Payment Preferences

But, How can I redirect the page, If transition done via Vica / Master Card ?


texts: Magento 1.9 Remove tax order works but shows shiping tax

texts:
I writing some codes for  remove all vat when order create (if some condition match) on Magento 1.9  file app/code/local/Mage/core/Sales/Model/Quote.php
inside collectTotals()
if(isset($_POST['vtvalidat']) && $_POST['vtvalidat'] =='true'){
                foreach($this->getAllVisibleItems() as $item) {
                $item->getProduct()->setTaxClassId(0);
            }
                }

This successfully removing product taxes but,
we have shipping fee it adding taxes i checked ways to remove that tax but can't find way,
Anyone know how to remove tax completely from a order programmatically, Thanks You


texts: Get product attribute value at cart page which is changed at product detailed page

texts:
I am developing one extension. I have created attribute at backend and assigned to product. And I am changing that product attribute while adding to cart and I am fetching same on checkout/cart page but I am not able to get same value on checkout/cart page.

I am storing this product value in checkout/cart model like this:

//saving product to cart
$product_id = Mage::app()->getRequest()->getPost('id');
        $qty = Mage::app()->getRequest()->getPost('qty');
        $product = Mage::getModel('catalog/product')->load($product_id);
        $product->setCanImage('wasdwasdwasd');

$cart = Mage::getModel('checkout/cart');
        $cart->init();
        $cart->addProduct($product, array('qty' => $qty));
        $cart->save();
        Mage::getSingleton('checkout/session')->setCartWasUpdated(true);
        Mage::getSingleton('core/session')->addSuccess('Product added successfully');

And I can retrieve my attribute value at same page like following code but I am not able to get it on checkout/cart page.

$cartQuote = Mage::getModel('checkout/cart')->getQuote()->getAllVisibleItems();
        foreach ($cartQuote as $item) {
            $productId = $item->getProduct()->getId();
            $productPrice = $item->getProduct()->getPrice();
            $item->getProduct()->getCanImage();//I can get my value here
        }

And I have used same code which is above but I am not getting value from checkout/cart quote.

And I don't want to store this value in database because it will create trouble if many user will add this product dynamically so I think quote is good place to keep data for product.

Please suggest me solution.


texts: Magento 2.3.2 free shipping cart rule not working

texts:
I'm trying to set up a cart rule in which I only offer free shipping
I added a new cart rule with these conditions:

Then I try to place an order, I choose 'Flat rate' as shipping method, I apply 'Test3' coupon code, but I don't see any discount in shipping amount.
Where is my mistake?


texts: Different registration forms on different websites

texts:
I need two different registration forms on two different websites. I separate websites like:

http://testmagento.devpassion.eu/website1 and
http://testmagento.devpassion.eu/website2

And in folder structure:

  /magento_folder/website1 and /magento_folder/website2

For now I just copy and change index.php and .htaccess to folders website1 and website2.

Should I copy all files and folders from root to website1 and website2 that corresponding to registration forms or there is some other why to separate this.

Also need register to two different customer group. So should I copy Accountcontroller.php to website1 and website2 folders?


texts: Stock Qty:40 Salable Quantity: 260. What has gone wrong?

texts:
Using Magento 2.3.2
I have a few products where the salable quantity is slightly more than the stock quantity, and one in particular which is WAY out. 40 in stock 260 salable. How do I reset the figures?
I have tried unassigning stock sources, and reassigning, but to no avail. Somewhere in my DB is 220 units that I can't find. Any help would be gratefully received.
TIA


texts: Can anyone explain to me, how magento cron_schedule exactly runs?

texts: When we run cron.php of magento then some jobs created in cron_schedule table of magento ? Can anyone let me know how magento execute these jobs exactly ? I mean how job status is changed from pending to success.  Cron.php only insert jobs in the table not execute jobs


texts:
Magento 2 question here:

I've made a custom attribute (media type) with the name of 'bike_range_image', and tried googling and searching in the core and everything I could to get the image with a custom size and such, but can't find the right approach.

I can get it as text, but obviously that's not enough, so this won't cut it:

$productImage = $product->getCustomAttribute( 'bike_range_image' );

Now, some examples in themes that are out there suggest I do this:

$this->helper('Magento\Catalog\Helper\Image')->init($product, 'bike_range_image');

But this gives me an enormous Magento\Catalog\Helper\Image object that doesn't seem to have the right data. (I've got the right product if you're wondering).

Does anyone have some pointers for me?


texts: Price.phtml and product.phtml is not working on my other store but working in may other store anyone can help?

texts: I have 2 stores, they have the same in price.phtml and product.phtml. But it is not working on my other store, can anyone help me ?


texts: Bundle products: display something other than full product name in selector?

texts:
This is easier to explain by example.

Let's say I sell T-shirts and other products. One shirt is available both alone and in a bundle with other products, and comes in several sizes. The shirt alone would be a configurable product, and when the customer views the product page they use a drop down with simple labels like "Size: Small" to select the size (and thus which simple product ends up in the cart).

With a bundle including the same shirt, the only way I can see to include it would be to have one of the bundle items have all of the simple products for the shirt. However, since it only seems to let you display the full product name, this means instead of a choice like "Size: Small" you get something like "Shirt: Example T-Shirt by Someguy Designs - Small". This makes for a messy and potentially confusing selection, especially with longer product names.

Is there a way to change the displayed text for a bundle option to something other than the full product name (ie "Small" instead of "Example T-Shirt by Someguy Designs - Small")? I know there are extensions that let you add configurable products to bundles and I imagine that might work in this particular example, but I'm looking for something a little more general if possible. There are other times where I would like to use something other than the full product name but don't have or want a configurable product to include instead.

I'd appreciate any help you could provide - thanks for your time!


texts: How to block Magento from Auto-sending CreditMemo after PayPal refund?

texts:
Basically, when I send refund via paypal to a customer, Magento automatically sends Credit Meme to the customer. Often time, the information is incorrect in the credit memo.

How to block Magento from automatically sending Credit Memo email after PayPal refund?

Does turning off IPN in PayPal settings will eliminate the automatic Credit Memo creation in Magento ?


texts: Can't save products after setting related items (Invalid argument supplied for foreach())

texts:
I'm trying to set related products programatically, using the following code:

$product = Mage::registry('current_product');
$id="549";
$data=array($id=>array('position'=>1));
$product->setRelatedLinkData($data);
$product->save();

And I'm getting:

Invalid argument supplied for foreach() in C:\Bitnami\magento-1.9.2.2-1\apps\magento\htdocs\app\code\core\Mage\Eav\Model\Entity\Abstract.php on line 1180

Looking at the source code doesn't give any useful information. its from here:

$origData = $newObject->getOrigData();
/**
* get current data in db for this entity if original data is empty
*/
if (empty($origData)) {
   $origData = $this->_getOrigObject($newObject)->getOrigData();
}

/**
* drop attributes that are unknown in new data
* not needed after introduction of partial entity loading
*/
foreach ($origData as $k => $v) { // <-- HERE!!!
    if (!array_key_exists($k, $newData)) {
       unset($origData[$k]);
    }
}

I looked at dozens of examples online of how to update related products and my code should be fine. without the save() there's no exception but nothing is saved either.

Any ideas?
Thanks!

EDIT: I also tried to load the $product I'm changing like this:

$product = Mage::getModel('catalog/product');
$product->load("754");

with hard-coded id, just to be sure.


texts: Magento rewrite category/product URLs leading to 404 page

texts:
I have many category and product URLs coming from google which gives 404 errors. The reason is google has indexed most of the pages without .html (from old site) while now I have all the pages with .html suffix. Is there anyway, without creating thousands of Catalog URL Rewrites, I can check as per the below rules?

http://www.example.com/this-is-bad => http://www.example.com/this-is-bad.html
http://www.example.com/this-is-bad.html => standard 404 error page
http://www.example.com/this-is-good => nothing to do, CMS page, already working
http://www.example.com/this-is-good/ => nothing to do, already working
http://www.example.com/this-is-good.html => nothing to do, already working

So if you have noticed, I only want to redirect without-.html 404 link TO with-.html valid link.
But also not to mess with working without-.html CMS pages.

Is it even possible with just .htaccess? Or how to approach this?

I'm using Enterprise 1.13 version on apache server, if this helps.

THANKS!


texts:
I added a button to admin order view which sends request to an url of an action controller (using ajax), and now I need to somehow make it available only for admin. What is the best solution for this problem? Also I can abandon ajax if there is a better option for the button.
Possible solution that occurred to me is to add something to header and then check it in the action function.


texts: Magento1.8.1.0 - Admin session timeout won't go above 15min

texts:
I have an issue with the Admin session timeout in Magento shop older version 1.8.1.0.

I have configured the value in seconds -> 3600 in Admin configuration but it still closes Admin session in 900 seconds.

I have checked the database and there is only

admin/security/session_cookie_lifetime 86200

There is no admin/security/session_lifetime as I have seen in some responses to this topic.

Could it be something in the PHP config? If it is, where could I find those variables?

Thanks


texts: Magento 2.2 - Unable to create customer attribute programatically using InstallData

texts:
I have created a new module to create customer attribute. The same was working perfectly in previous magento 2 versions. But in magento 2.2 its not working. Could you pls check into that.

<?php
namespace Mymodule\AttributeManager\Setup;

use Magento\Customer\Setup\CustomerSetupFactory;

use Magento\Customer\Model\Customer;

use Magento\Framework\Module\Setup\Migration;

use Magento\Framework\Setup\InstallDataInterface;

use Magento\Framework\Setup\ModuleContextInterface;

use Magento\Framework\Setup\ModuleDataSetupInterface;

class InstallData implements InstallDataInterface
{

    private $customerSetupFactory;

    /**
     * Init
     *
     * @param CustomerSetupFactory $customerSetupFactory
     */
    public function __construct(CustomerSetupFactory $customerSetupFactory)
    {
        $this->customerSetupFactory = $customerSetupFactory;
    }

    /**
     * {@inheritdoc}
     * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
     */
    public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
    {

        /** @var CustomerSetup $customerSetup */
        $customerSetup = $this->customerSetupFactory->create(['setup' => $setup]);

        $setup->startSetup();

        $attributesInfo = [
            'nettermspo' => [
                'user_defined' => true,
                'position' =>99,
                'type' => 'int',
                'label' => 'Is eligible for NET TERMS PO ?',
                'input' => 'select',
                'sort_order' => 99,
                'source' => 'Magento\Eav\Model\Entity\Attribute\Source\Boolean',
                'global' => 1,
                'default' => 0,
                'visible' => true,
                'required' => false,
                'system' => 0,
                'group' => 'Account Information',
            ]
        ];

        foreach ($attributesInfo as $attributeCode => $attributeParams) {
            $customerSetup->addAttribute(Customer::ENTITY, $attributeCode, $attributeParams);
        }
        $nettermspoAttribute = $customerSetup->getEavConfig()->getAttribute(Customer::ENTITY, 'nettermspo');
        $nettermspoAttribute->setData(
            'used_in_forms',
            ['adminhtml_customer']
        );
        $nettermspoAttribute->save();
        $setup->endSetup();
    }
}


texts: Display Configurable Swatches in subcategories displayed on parent category page?

texts:
Having a bit of a strange issue here, with a very unique scenario.

Currently my main categories have no products, but they have a child category with products, and a grandchild category with products, that all show up on the main category page.

list.phtml

$category = Mage::getSingleton('catalog/layer')->getCurrentCategory();
$childCategories = $category->getChildren();

foreach(explode(',',$childCategories) as $childId):

$childCategory = Mage::getModel('catalog/category')->load($childId);

This has allowed me to pull the product collection from the children categories just fine, as well as the child category name, description, etc. I have the full grid of products rendering just fine except for the configurable swatches.

Here is the bit of php for the configurable swatches which is misbehaving:

if ($this->getChild('name.after')) {
    $_nameAfterChildren = $this->getChild('name.after')->getChildren();
        foreach ($_nameAfterChildren as $_nameAfterChildName) {
            $_nameAfterChild = $this->getChild('name.after')->getChild($_nameAfterChildName);
            $_nameAfterChild->setProduct($_gcProduct);
            echo $_nameAfterChild->toHtml();
        }
}

It doesn't render anything. However if I put an 'echo "Hello!";' after the if statement, that shows up.. so it thinks it's true. I've tried changing $this to $childCategories (which can be used to access the full category) but still nothing shows up for the swatches.

Any suggestions/ideas?


texts: How to add image upload option in product custom options magento 2?

texts: I would like to show custom options all values with their image icon for that I need to add the image with each custom option value. Please do not suggest any paid extension or module.


texts: Model setData dateTime field set current date

texts:
I have an extension attribute for a dateTime field in sales_order table.

What I want to do on a certain action is to set the value of this field to NOW().

How can I perform this?

$order->setData('my_date_time_field', WHAT_SHOULD_I_WROTE_HERE?);

Now I am using the Magento stdLib\DateTime class to get the data, I just want sql to use it's own NOW() function.


texts: Reference the shopping cart items template

texts:
I am trying to change the way the products are shown in the shopping cart, for bundle products. I have a template that will deal with that. So I have created a layout xml file where I reference the normal template, but when I try to open the shopping cart - it doesn't load and just downloads me some weird file.

Here's the code in the layout file:

<checkout_cart_index>
        <reference name="checkout.cart">
            <action method="addItemRender">
                <type>bundle</type>
                <block>quotationitemprice/bundle_sales_order_items_renderer</block>
                <template>company/quotationitemprice/bundle/sales/order/items/renderer.phtml</template>
            </action>
        </reference>
    </checkout_cart_index>

It works for the order overview, that's why I was wondering what's the problem here..

P.S. I put a simple Mage::log('I am here') in the beginning of the template, just to test, but it seems that it doesn't get in the template at all, since I don't get anything logged.


texts: Magento 2 How to add custom field in customer_address_entity table? which will not use for front end or back end

texts:
I want to add one custom field in "customer_address_entity" table, for custom module. I have custom module installed. I am trying with "InstallData" script to add custom field. I do not want to show that field in front end or admin side.

below is my code

<?php

namespace Name\Module\Setup;

use Magento\Eav\Setup\EavSetupFactory;
use Magento\Framework\Setup\InstallDataInterface;
use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\ModuleDataSetupInterface;

class InstallData implements InstallDataInterface
{

 private $eavSetupFactory;

  public function __construct(EavSetupFactory $eavSetupFactory)
    {
        $this->eavSetupFactory = $eavSetupFactory;
    }

public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
    {
        $setup->startSetup();

        /** @var \Magento\Eav\Setup\EavSetup $eavSetup */
         $eavSetup = $this->eavSetupFactory->create(['setup' => $setup]);

         $eavSetup->addAttribute('customer_address', 'location_id', array(
            'type' => 'int',
            'input' => 'text',
            'label' => 'Location Id',
            'global' => 1,
            'visible' => 0,
            'required' => 0,
            'user_defined' => 1,
            'system'=>0,
            'visible_on_front' => 0,
        ));
        $eavSetup->getEavConfig()->getAttribute('customer_address','location_id')
       //->setUsedInForms(array('adminhtml_customer_address','customer_address_edit','customer_register_address'))
               ->save();
         $setup->endSetup();

   }
}


texts: How to overwrite customer registration REST API in magento 2.3

texts: Any once please help me out for overwrite the REST api in magento 2.3 please describe with example.


texts: Disable registration and login and buying with money

texts: Can I disable magento's registration and login features, so it could work without checkouts. If customer wants to buy a product, he must recieve an email from magento with bank credinationals of the magento's shop owner. Is it possible?


texts: I was wondering how to customize the magento 2 menu as shown below.. Is someone have a clear idea about that ?


texts: Layered Navigation doesn't show Custom Attribute

texts:
I have created custom attribute with multiselect option using code. Its created all the custom attributes, After product Import, multiselect attribute not coming to Shopping options. But viewed in Product Details.

If i created custom attribute manually its viewed in Shopping Options but, using code its created , but not viewed in shopping option.

reference:

This is my code:

   $eavSetup->addAttribute(

        \Magento\Catalog\Model\Product::ENTITY,
        'c_bathrooms',/* Custom Attribute Code */
        [
            'group' => 'Product Details',/* Group name in which you want to display your custom attribute */
            'type' => 'text',/* Data type in which formate your value save in database*/
            'attribute_set' =>  'Attribute Name',
            'backend' => '',
            'frontend' => '',
            'label' => 'Bathrooms', /* lablel of your attribute*/
            'input' => 'multiselect',
            'class' => '',
            'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE,
            'visible' => true,
            'required' => true,
            'user_defined' => true,
            'default' => '',
            'searchable' => true,
            'filterable' => true,
            'comparable' => true,
            'visible_on_front' => true,
            'used_in_product_listing' => true,
            'unique' => false,
            'visible_in_advanced_search' => true,
            'filterable_in_search' => true,
            'option' => [
                'values' => [
                    '1',
                    '2',
                    '3',
                    '4',
                    '5'
                ]
            ]
        ]
    );

Suggest me, What i Miss and how to fix this issue

Note: if I remove and recreate CustomAttribute, Some custom custom attribute view. not all the multiselect option attribute viewed.


texts: Is it possible to truncate catalog_product_index_price without causing problems to the actual products?


texts: How to add dynamic row in grid edit form in custom module in magento 2

texts:
can any one idea for how to add dynamic row in add grid data form in Magento 2

I want to manage the app screen section for example in one section i add multiple banner data so how can i mange it
i know i manage it from dynamic row but how can i add dynamic row in admin grid form


texts: Magento 2 - Update eav attributes in a other attribute automatically

texts:
we have a multi brand shop with 60K+ of products.
Every brand has it's own way of dimensions.
Which results in an attribute list of 500+ entries.
Attribute: POS-size
Here is a screenshot of this:

But this list is to big to use for a filter on front-end.
Thats why we have added an extra attribute for this. To simplify all these sizes.
This attribute is: size-frontend
Here is a screenshot:

After I have made new products (added via a POS system) I have to manually update the simple product with the size-frontend attribute.
Some examples:
Pos-size -> size-frontend
50 -> 50
50/56 -> 50 & 56
56 -> 56
56/62 -> 56 & 62
56-62 -> 56 & 62
This costs a lot of time, and I think think this could be done automatically (through a script or an extension) after making some kind of conversion table.
And it should also be able to give an starting product-id, from where it should start.
Does anyone know how to do this? Or know an extension which can do this?
It should be done in the backend, in a special screen like this:

Now i have to filter the products on the pos-size, than update these products in bulk to the desired filterable attribute size(s)
It would be nice if i could run this by selecting the desired products and apply this action. WHich could be placed in the actions menu with the products


texts: How to make the second address field required on checkout page on Magento 2

texts:
Magento 2 has a option to extend the address field up to 4 fields.

This configuration can be found at:

  Store->Configuration->Customer->Customer Configuration->Name and
  Address Option

and there is a tab called Number of Lines in a Street Address.

Now all I want is to make the second field required like how the first field is required by default.

Does anyone know a solution?


texts: Display products by catalog using REST api in Magento 2?

texts:
Problem:

I am trying to display products using below rest api with ref http://devdocs.magento.com/guides/v2.0/rest/retrieve-filtered-responses.html

GET http://192.168.0.133/index.php/rest/V1/products/?searchCriteria[filter_groups][0][filters][0][field]=category_gear&searchCriteria[filter_groups][0][filters][0][value]=8&searchCriteria[filter_groups][0][filters][0][condition_type]=finset&fields=items[sku,name]

I am getting response as

{
"items": null
}

Whereas I have 4 products in category/catalog with id=8

What is the correct way to call the api ?

I am using magento 2.2.1


texts: Magento2 hide 'Skip to the beginning of the images gallery'

texts:
I want to hide 'Skip to the beginning of the images gallery' message from product details page.I am always going to have only single image for all products so I need to hide the message.

How can I achieve this?


texts: Remove comma generated by multiple select attribute

texts:
I have created an multiple select attribute, visible on the frondend, it is generated with a comma as a seperator, does anyone know how to remove this comma between the shown values?

Thanks


texts:
I'm slowly setting up my shop. All products are available to view and shop is enabled for external visitors, for SEO purposes. However I don't want to sell anything right now.

What is the easiest way to switch off Magento checkout page - how to disable making orders?


texts: Create a detail listing page of a record on admin side

texts: I want to create a page like an edit page of an model where user cannot change any content. He can only see the content. How can i achieve it?


texts: Magento Sorting by position in Custom Product Listing

texts:
First, I've searched Google, SO, and magento SE to no avail.  I've seen many results, but none that seemed to work.

I've got a "custom" product listing on the front-end, which uses the below code:

$magentoProduct = Mage::getModel('catalog/product');
$_helper = $this->helper('catalog/output');

$collection = $magentoProduct->getCollection()
            ->addAttributeToSelect('*')
            ->addAttributeToFilter('status', 1)
            ->setStoreId(Mage_Core_Model_App::ADMIN_STORE_ID);
// This doesn't have any effect
//          ->setOrder('position', 'ASC');

$collectionIds = $collection->getAllIds();
foreach ($collectionIds as $prodId):
    $magentoProduct->reset();
    $magentoProduct = $magentoProduct->load($prodId);
    $cats = $magentoProduct->getCategoryIds();
    // ... do stuff ...
endforeach;

I want the sort order to respond to the Product Position (as set in the "Catalog"=>"Manage Categories" interface).

I've tried a variety of things, to no avail.

Any insights?  (I'm also open to a better / different approach to this, so feel free to suggest best practices).


texts:
I have MAMP & MAMP PRO.

I tried to install Magento 2 beta. When i write "composer install" the system returns  me this error:

Your requirements could not be resolved to an installable set of packages.

Problem 1
    - The requested PHP extension ext-mcrypt * is missing from your system.

I have check the services of system and mcrypt is enabled.

How i can solve?

Thanks


texts: Magento 2.3.5 admin password reset link expired

texts: If I try to reset password via admin login's "forgot password?" functionality, the link sent to reset password is expired immediately. I have the Recovery Link Expiration Period set to 10 hours. Any ideas?


texts: Unable to display database table values on frontend in magento 2.1.7

texts:
I am trying to fetch table on frontend but getting this error

  Fatal error: Class 'Crud\Crudatfrontend\Model\ResourceModel\Post' not
  found in
  D:\xampp\htdocs\newmag\vendor\magento\framework\ObjectManager\Factory\AbstractFactory.php
  on line 93

app/code/Crud/Crudatfrontend/
├── Block
│   └── index.php
├── etc
│    └── module.xml
├── Model
│   ├── Post.php
│   ├── ResourceModel
│   │   ├── Post
│   │   │   └── Collection.php
│   │   └── Post.php
├── registration.php
├── Setup
│   └── InstallSchema.php
└── view
    └── frontend
        ├── layout
        │   └── crud_index_index.xml
        ├── templates
            └── index.phtml

Here is my code,

  Block/Index.php

<?php

namespace Crud\Crudatfrontend\Block;

use Magento\Framework\App\Filesystem\DirectoryList;

class Index extends \Magento\Framework\View\Element\Template
{
    protected $_filesystem;

    public function __construct(
        \Magento\Framework\View\Element\Template\Context $context,
        \Crud\Crudatfrontend\Model\PostFactory $postFactory
        )
    {
        parent::__construct($context);
        $this->_postFactory = $postFactory;
    }

    public function getResult()
    {
        $post = $this->_postFactory->create();
        $collection = $post->getCollection();
        return $collection;
    }
}

  Model/Post.php

<?php
namespace Crud\Crudatfrontend\Model;
class Post extends \Magento\Framework\Model\AbstractModel implements \Magento\Framework\DataObject\IdentityInterface
{
        protected function _construct()
        {
                $this->_init('Crud\Crudatfrontend\Model\ResourceModel\Post');
        }

        public function getIdentities()
        {
                return [self::CACHE_TAG . '_' . $this->getId()];
        }

        public function getDefaultValues()
        {
                $values = [];

                return $values;
        }
}

  Model\ResourceModel\Post.php

<?php

namespace Crud\Crudatfrontend\Model\ResourceModel;

use \Magento\Framework\Model\ResourceModel\Db\AbstractDb;

class HelloWorld extends AbstractDb
{
    /**
     * Model initialization
     */
    protected function _construct()
    {
        $this->_init('Crud_Crudatfrontend', 'post_id');
    }
}

  Model\ResourceModel\Post\collection.php

<?php
namespace Crud\Crudatfrontend\Model\ResourceModel\Post;

class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection
{
        /**
         * Define resource model
         *
         * @return void
         */
        protected function _construct()
        {
                $this->_init('Crud\Crudatfrontend\Model\Post', 'Crud\Crudatfrontend\Model\ResourceModel\Post');
        }
}


texts: Magento 2.3.2 - Saving categories after data migration causes empty records

texts:
I have imported my cats and products from Magento 1 into Magento 2.  The categories show in the front end but it states that no products can be found.  In the admin, the cats show, with their products.

However, on adding a new sub cat, the record appears to save but gets added onto the tree with an empty name. Loading it shows all data is blank. Trying to edit an existing (imported category) also results in the data to become blank.  I noticed in the catalog_category_entity table that all the imported cats (which are showing on the front end, albeit without products showing) have an attribute_set_id of 3 but the new ones I am trying to create, or edit, end up with an attribute_set_id of 20.

---- update ---

I have taken a look at the eav_attribute_set table and can see why there is a problem. I just don't know what to do about it yet.  All object types have two references, the one from the migration and default. Here are the entries for type 3 (Categories).

attribute_set_id   |   entity_type_id   | attribute_set_name
...
        3          |           3        |  Migration_Default
...
        20         |           3        |  Default

Any ideas on how to sort this pickle?


texts: How to show the newsletter with user name option in footer

texts: Can anyone suggest me how to show the newsletter with username option in the footer? Please check the reference site: http://www.oculosshop.com.br/.


texts: How to get custom table from data fetch by form id in magento 2.3.1

texts:
How to get custom table form table by form_id for custom table in magento 2.3.1?
try this but it's not working
custom table screen short:

Vendor\Module\Block\Form.php

 <?php

 namespace Vendor\Module\Block;

class Form extends \Magento\Framework\View\Element\Template
{
   protected $collectionFactory;

   public function __construct(
    \Magento\Framework\View\Element\Template\Context $context,
    \Vendor\Module\Model\ResourceModel\ContactForms\CollectionFactory $collectionFactory
) {
    $this->collectionFactory = $collectionFactory;
    parent::__construct($context);
}

 public function getLoadForm($form_id)
  {
    return $this->collectionFactory->create()->load($form_id);
  }
}

customTemplate.phtml

<?php
   $formsCollection = $block->getLoadForm(form_id);

   echo $formsCollection->getTitle();
?>


texts: How do i add simple products to configurable product?

texts: How do i add simple products under configurable products? I've created the simple products separately and before the configurable products, so they are standalone products.


texts: Magento 2 Repositories and Database Transactions

texts:
Almost every post I read states that I should be working on objects using Magento 2 repositories rather that instantiating objects using Magento 2 object factories.

That's what I started to do, and all was great until I wrote an small extension to programatically create a shipment whilst also writing a comment to the orders history table.

I would have expected to do something like this in a database transaction, so if there's a failure everything gets rolled back, but I just can't see how to use database transactions with repositories.

If I do something like

$order = $this->orderRepository->get($orderId);

$order->setSomething('something');

$transaction = $this->transactionFactory->create();

$transaction->addObject($order);

I get a warning in phpStorm of: Expected \Magento\Framwork\Abstract\Model, got \Magento\Sales\Api\Data\OrderInterface. Basically it looks like the database transaction object is expecting factory generated Models rather than repository generated objects. Does that mean that repositories don't actually support database transactions?


texts: How to add js file to admin category edit via xml?

texts:
I have created a module and I am trying to include a custom js file into the category edit page.

In my config.xml file I have:

<config>
    ...
    <adminhtml>
        <layout>
            <updates>
                <my_module>
                    <file>my_module.xml</file>
                </my_module>
            </updates>
        </layout>
    </adminhtml>
</config>

And in my app/design/adminhtml/default/default/layout/my_module.xml file I have:

<?xml version="1.0"?>
<layout>
    <adminhtml_catalog_category_edit>
        <reference name="head">
            <action method="addJs"><script>my_js_file.js</script></action>
        </reference>
    </adminhtml_catalog_category_edit>
</layout>

According to all references, this should work, but when I view the source of the category edit page, I do not see it being included in the head.

What am I doing wrong? Why is my file not being included?


texts: login to magento community backend-Invalid Secure BaseURL Store: default Wrong hostname configured. Hostname must contain a dot

texts:
like always windows OS is driving me crazy.I have localhost and I did run n98-magerun sys:check for troubleshoot magento and I know the problem as follows:

Invalid Secure BaseURL Store: default Wrong hostname configured. Hostname must
contain a dot

through installation when magento asked me to enter the host name I did use 127.0.0.1 instead of localhost,
I tried to use www.localhost.com to solve the problem in the hosts file of
 located in C:\Windows\System32\drivers\etc

127.0.0.1       www.localhost.com

then I went to httpd.conf  and I did the following:

<VirtualHost *:80>
    ServerAdmin webmaster@dummy-host.example.com
    DocumentRoot "c:/wamp/www/magento"
    ServerName localhost.com
    ServerAlias www.localhost.com
    ErrorLog "logs/dummy-host.example.com-error.log"
    CustomLog "logs/dummy-host.example.com-access.log" common
</VirtualHost>

I didn't change Logs because I didn't need them then in .htaccess of magento I wrote this:

 Order allow,deny
    Allow from all

if I enter localhost/magento/admin and enter user,pass I cannot
login
if I enter www.localhost.com/admin it will go to admin it will redirect to

http://localhost/magento/index.php/admin/dashboard/index/key/blahblah

and I can see the page:

but if I click on any link again I will be signed out because the domain is localhost and doesn't have dots

I tried to go core_config_data table and search for the base url, I didn't find anything

I tried every solution on the internet, literally everything.

P.S:I just found out that I can login through firefox but not chrome, I know the solution of changing Varien.php but I don't like it and I don't want to change core files it should have a better solution

P.S: As adeel said I increased cookie life time in php.ini from 0 to 3600

session.cookie_lifetime = 3600

still not working in chrome


texts: Magento 2.3.3 - 502 Bad Gateway - Centos - Nginx

texts:
After placed Magento 2.3.3 files to usr/share/nginx/html/magento & created database then run following,

php bin/magento setup:install --base-url=http://192.168.1.64/magento --db-host=localhost --db-name="magento" --db-user="root" --db-password="" --admin-firstname="abc" --admin-lastname="abc" --admin-email=abc@gmail.com --admin-user="magento" --admin-password="magento" --language="en_US" --currency="INR" --timezone="Asia/Kolkata" --use-rewrites="1"

and also edit etc/nginx/conf.d/magento.conf

upstream fastcgi_backend {
  server unix:/run/php-fpm/php-fpm.sock;
}

server {

  listen 8091;
  server_name http://192.168.1.64:8091/;
  set $MAGE_ROOT /usr/share/nginx/html/magento;
  include /usr/share/nginx/html/magento/nginx.conf.sample;
}

  Screenshot : https://snipboard.io/K5t9Qm.jpg

How to solve 502 bad gateway error?

Note : <?php phpinfo(); ?> -> test.php inside /usr/share/nginx/html php info page return 502 bad gateway error.


texts:
I have moved my Magento code base to another folder and I have upgraded the php version to php7. Now I am facing the following error.

  SessionHandler::read(): Session data file is not created by your uid
  Warning: SessionHandler::write(): Session data file is not created by
  your uid in
  /var/www/html/vendor/magento/framework/Session/SaveHandler.php on line
  105

  Warning: Unknown: Failed to write session data (user). Please verify
  that the current setting of session.save_path is correct
  (/var/www/html/var/session/) in Unknown on line 0

Help me to fix this


texts: Call current product in custom phtml file in Magento 2

texts:
On the product page I created a custom module to override the form.phtml file.
I also added the option to include a new file called customFile.phtml when the user clicks on a button that is positioned under the product description.
In this customFile.phtml file I am trying to retrieve the current product data but it doesn't work. I also injected the class to take on the function of the current product but it doesn't work and gives me "Fatal error".
This is the xml of my customFile.phtml file which is called on click with Ajax:
<?xml version="1.0"?>

<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/layout_generic.xsd">
<container name="product.info.form.content" as="product_info_form_content">
    <update handle="catalog_product_opengraph" />
    <update handle="page_calendar"/>
    <block class="Magento\Framework\View\Element\Template" name="customFile" template="Catalog_Product::customFile.phtml"/>
</container>
</layout>

This instead is the phtml code of the file:
<?php
$_product = $block->getLayout()->createBlock('Catalog\Product\Block\ProductInfo')->getCurrentProduct();

echo $_product->getName();
?>

This is the class where I call the current product in my custom file:
    <?php
    namespace Catalog\Product\Block;

    use Magento\Framework\View\Element\Template;

    class ProductInfo extends Template
    {
    protected $_registry;

public function __construct(
    \Magento\Backend\Block\Template\Context $context,
    \Magento\Framework\Registry $registry,
    array $data = []
)
{
    $this->_registry = $registry;
    parent::__construct($context, $data);
}

public function _prepareLayout()
{
    return parent::_prepareLayout();
}

public function getCurrentCategory()
{
    return $this->_registry->registry('current_category');
}

public function getCurrentProduct()
{
    return $this->_registry->registry('current_product');
}

}
?>

I FOUND THE MISTAKE:
Calling the customFile.phtml file with ajax I created his xml file for the link and it's called customfile_index_edit.xml and consequently the current link is www.magento2.com/customfile/index/edit. Maybe that's why Magento doesn't give me back the information of the current product.
What could I do at this point?
Thank you


texts: Shipping credit memo applies taxes twice

texts:
When I create a new credit memo for shipping costs the shipping taxes are calculated twice:

Notice: Before, I created a credit memo for the product price to have a better overview what happens with the shipping refund.

4,95 are the shipping costs (incl. taxes). The problem is, that magento adds the taxes (0,79) again.

Here is a full example:

This is an offline example, but when I try to refund payments made with RatePay or PayPal, they receive a refund request 0,79€ higher than the price paid before.

Has anybody experienced something like that before and has an idea what is happening here? Where should I start to look for the root of this problem? Maybe I can fix the problem in a submodule.

The price calculation works anywhere else correctly.


texts: Magento 2 - Move the afterMethods item (Discount and Gift Card Code) to the Order Summary sidebar

texts:
I would like to move the afterMethods xml item which contains the Discount Code and Gift Card code under the billing-step in the module-checkout/view/frontend/web/checkout_index_index.xml so that it is displayed below the shipping-information item in the sidebar

Snippet of the afterMethods:

<!-- merge your payment methods here -->
<item name="afterMethods" xsi:type="array">
    <item name="component" xsi:type="string">uiComponent</item>
    <item name="displayArea" xsi:type="string">afterMethods</item>
    <item name="children" xsi:type="array">
        <!-- merge additional data after payment methods here -->
    </item>
</item>

Here is a screenshot of my current checkout/payment page:

Since it is not a block or a container I am not quiet sure the proper steps to move the item.


texts: Magento 2.2 error when di:compile is run

texts:
Error:

  Errors during compilation:
          Tdsoft\Pdfbuilder\Model\ResourceModel\Invoice\Grid\Collection
                  Incompatible argument type: Required type: \Magento\Framework\DB\Adapter\AdapterInterface. Actual type: \Tdsoft\Pdfbuilder\Model\ResourceModel\Invoice\Grid\connection; File:
  /home/sertarul/public_html/app/code/Tdsoft/Pdfbuilder/Model/ResourceModel/Invoice/Grid/Collection.php

Total Errors Count: 1

Collection.php content:

 public function __construct(
    \Magento\Framework\Data\Collection\EntityFactoryInterface $entityFactory,
    \Psr\Log\LoggerInterface $logger,
    \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy,
    \Magento\Framework\Event\ManagerInterface $eventManager,
    $mainTable,
    $eventPrefix,
    $eventObject,
    $resourceModel,
    $model = 'Magento\Framework\View\Element\UiComponent\DataProvider\Document',
    $connection = null,
    \Magento\Framework\Model\ResourceModel\Db\AbstractDb $resource = null
)
{
    parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $connection, $resource);
    $this->_eventPrefix = $eventPrefix;
    $this->_eventObject = $eventObject;
    $this->_init($model, $resourceModel);
    $this->setMainTable($mainTable);
}


texts:
I am trying to add canonical links with trailing forward slashes removed to my site's blog pages via:

<?php
$currentUrl = rtrim(Mage::helper('core/url')->getCurrentUrl(),'/');
$blogUrl = rtrim($this->getLayout()->getBlockSingleton('blog/blog')->getBlogUrl(),'/');

if ($currentUrl == $blogUrl) : ?>
    <title><?php echo $blogHelper->getTitle() ?></title>
    <link rel="canonical" href="<?php echo $blogUrl ?>" />
<?php endif; ?>

I don't want to rewrite Magento's getUrl method, so I figured I could just remove trailing forward slashes with rtrim.

However, whenever I turn on "Blocks HTML Output" caching in Magento admin, the forward slashes return!

What I want:

mysite.com/blog

What I'm getting:

mysite.com/blog/

What's going on here and how can I fix it?

EDIT :

I thought this could be a problem with the getBlockSingleton method, so I tried using a model instead, via a getSingleton method, and still had the same problem: rtrim gets ignored.

Even rtrim($blogUrl,'/') (i.e. using rtrim again) gets ignored.

Solved the problem by building the URL up using the base url and a helper:

$blogUrl = rtrim($this->getBaseUrl().Mage::helper('blog')->getRoute(),'/');

The rtrim was unneeded there but I used it just in case.


texts:
(This is the plugin I am trying to use)
http://zurb.com/playground/twentytwenty

I have

app/design/frontend/myvendor/mytheme/requirejs-config.js

and it looks like:

var config = {
    map: {
        'eventmove':        'Magento_Theme/js/jquery.event.move',
        'twentytwenty':     'Magento_Theme/js/jquery.twentytwenty'
    },
    shim: {
        'twentytwenty': {
            deps: ['jquery']
        }

   }

};

cleared pub folder, set development mode, re-compile, deploy static files...

viewing source on front end reveals the js files are not loaded.

also, this is the code on the detail page that it needs, I dont knwo if it's formatted right or not since requirejs isnt working.

<script>
    require([
    'jquery',
    'eventmove',
    'twentytwenty'
    ], function () {
      jQuery(document).ready(function() {
          jQuery(window).load(function() {
          jQuery(".twentytwenty-container").twentytwenty();
      });
    });
</script>

EDIT


texts: Upgrade 1.9.1 Google Analytics not tracking anymore

texts:
Since upgrading from Magento CE 1.7.0.2 to 1.9.1 its not showing any visitors. Google is activated and I use the Fooman extension.

Any ideas why its not tracking visitors?

Thanks.


texts: Magento2 multiple webservers static directory

texts:
I'm trying to run Magento2 on multiple webserves behind a load balancer. So far I have

sessions stored in database
app/etc/env.php shared across webservers
running the site in production mode

The media directory is mounted on NFS.

I want to understand how generated static content fits into this paradigm. At some point I need to run bin/magento setup:static-content:deploy, but it looks like it needs database access to work?

I'm trying to produce a 'build' of the application including the generated files so ideally, there'd be some way to do this without the need for connecting to the database.

Can I generate the static content without database connectivity?


texts: Send checkout link after order placed by Magento Backend

texts:
I'm using Magento 2.3.5 for B2B sales.
My "Sales Man" needs to create an order using Magento backend (admin panel) and after que creation of the order, get a link of checkout to send to the customer.
So the customer will enter on checkout link and just make the payment.
How can i do that ?
Is possible to create a module for this ?  Or are there any extesion available on market for this ?
Thanks.


texts:
Is there any reason why there is no index on the entity_id column on the url_rewrite table? Or on entity_id and entity_type?
The only index I see is on entity_id and store_id.
I understand that that usually a select is done on entity_id AND store_id but still...
Side question...
are there any drawbacks if I add this index myself?

For the record, this is what show create table url_rewrite shows:

CREATE TABLE `url_rewrite` (
  `url_rewrite_id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Rewrite Id',
  `entity_type` varchar(32) NOT NULL COMMENT 'Entity type code',
  `entity_id` int(10) unsigned NOT NULL COMMENT 'Entity ID',
  `request_path` varchar(255) DEFAULT NULL COMMENT 'Request Path',
  `target_path` varchar(255) DEFAULT NULL COMMENT 'Target Path',
  `redirect_type` smallint(5) unsigned NOT NULL DEFAULT '0' COMMENT 'Redirect Type',
  `store_id` smallint(5) unsigned NOT NULL COMMENT 'Store Id',
  `description` varchar(255) DEFAULT NULL COMMENT 'Description',
  `is_autogenerated` smallint(5) unsigned NOT NULL DEFAULT '0' COMMENT 'Is rewrite generated automatically flag',
  `metadata` varchar(255) DEFAULT NULL COMMENT 'Meta data for url rewrite',
  PRIMARY KEY (`url_rewrite_id`),
  UNIQUE KEY `URL_REWRITE_REQUEST_PATH_STORE_ID` (`request_path`,`store_id`),
  KEY `URL_REWRITE_TARGET_PATH` (`target_path`),
  KEY `URL_REWRITE_STORE_ID_ENTITY_ID` (`store_id`,`entity_id`)
) ENGINE=InnoDB AUTO_INCREMENT=26 DEFAULT CHARSET=utf8 COMMENT='Url Rewrites'


texts: How to make custom module menu tab selected in backend

texts:
<menu>
      <place module="place">
        <title>Model</title>
        <sort_order>100</sort_order>

        <action>place/adminhtml_place</action>
      </place>
    </menu>

This is Custom module menu tab. I click on it, it doesn't get selected. I tried to add active CSS class to it using liParmas but it doesn't add the class. If anyone know any simple trick to make it selected, please share.


texts:
I have one extension A that uses observer for "couponPost" action.

I'm developing extension B that uses observer and need to have "couponPost" action name in it.

If I use <depends/> in my extension B with A as dependent then extension A has couponPost action, but B doesn't have.

How do I get same post action name in extension B ?

Note: extension A is a 3rd party extension.

Thanks in advance.


texts: What is difference between getOrderId and getLastRealOrder() function in magento 2?

texts:
As I'm new to magento 2 I can't anble to trigger out the difference between getOrderId and getLastRealOrder function ?

How to get product id using getLastRealOrder() function?


texts: Magento 2 set order status to processing when paid off by coupon

texts:
I did notice a setting where you can change order status when subtotal is zero:

A) Stores / Configuration / Sales / Payment Methods / Other Payment Methods / Zero Subtotal Checkout

I have also tried the solution mentioned here:

B) Magento 2: How to update order status programmatically in custom module?

and both fails, any ideas?


texts: how to use different template file for category magento 2

texts:
I want to customize the design of the catalog list page. I want to use different layout and design for each product category. For that, I am calling different phtml files from static block. using a static block I am calling another phtml file but still in product list page default Magento list.phtml files are load. I don't know what actually issue please help me!

I am using Magento 2.1.1 version


texts: magento1.9 sms for customer when order placed

texts: Is there any sms extension available for free to send transaction sms like order confirmation or any less amount of extension suggest me. Am using magento 1.9.3


texts:
I have uploaded my website from local environment to a live server.  I changed the config.xml file and removed the local.xml file but it is causing the following error:

    Warning: include(Mage/Core/Controller/Varien/Router/Admin.php): failed to open stream: No such file or directory  in /home1/belghiti/chamsse.ma/BETA/chamsse/lib/Varien/Autoload.php on line 94

#0 /home1/belghiti/chamsse.ma/BETA/chamsse/lib/Varien/Autoload.php(94): mageCoreErrorHandler(2, 'include(Mage/Co...', '/home1/belghiti...', 94, Array)
#1 /home1/belghiti/chamsse.ma/BETA/chamsse/lib/Varien/Autoload.php(94): Varien_Autoload::autoload()
#2 [internal function]: Varien_Autoload->autoload('Mage_Core_Contr...')
#3 /home1/belghiti/chamsse.ma/BETA/chamsse/app/code/core/Mage/Core/Controller/Varien/Front.php(138): spl_autoload_call('Mage_Core_Contr...')
#4 /home1/belghiti/chamsse.ma/BETA/chamsse/app/code/core/Mage/Core/Model/App.php(764): Mage_Core_Controller_Varien_Front->init()
#5 /home1/belghiti/chamsse.ma/BETA/chamsse/app/code/core/Mage/Core/Model/App.php(1113): Mage_Core_Model_App->_initFrontController()
#6 /home1/belghiti/chamsse.ma/BETA/chamsse/app/code/core/Mage/Core/Model/App.php(365): Mage_Core_Model_App->getFrontController()
#7 /home1/belghiti/chamsse.ma/BETA/chamsse/app/Mage.php(684): Mage_Core_Model_App->run(Array)
#8 /home1/belghiti/chamsse.ma/BETA/chamsse/index.php(83): Mage::run('', 'store')
#9 {main}


texts: Magento2 After Sync Images To Amazon S3 All Images from Magento are Deleted

texts:
I have create one module to sync all magento2 media  to amazon s3
but after sync to amazon s3 server my all magento media's are deleted  from my local system.
and i don't want to remove that media.
Does anyone know how i can solve this problem ?

I have create my custom command to export media

php bin/magento amazons3:media:export


texts: How to set sort order while add attribute programmatically

texts:
I want to set sort order in attribute. In mysql file i m used this

  'sort_order' => 10

but it not worked

[Edit]

$installer->addAttribute('customer','badge', array(
    'label'             => 'Badge',
    'type'              => 'text',    //backend_type
    'input'             => 'multiselect', //frontend_input
    'backend'           => 'eav/entity_attribute_backend_array',
    'global'            =>  Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
    'source'            => 'marketplace/eav_entity_attribute_source_badge', // Goes to Step 2
    'visible'           => true,
    'required'          => false,
    'default'           => '',
    'frontend'          => '',
    'unique'            => false,
    'note'              => '',
    'sort_order'        => 10

));
Mage::getSingleton('eav/config')
    ->getAttribute('customer', 'badge')
    ->setData('used_in_forms', array('customer_account_create','customer_account_edit','customer_address_edit','checkout_onepage_register','checkout_onepage_register_guest','checkout_onepage_billing_address','adminhtml_customer','checkout_onepage_shipping_address','checkout_multishipping_register'))
    ->save();


texts: While running Cron through Command prompt getting "exec function is disabled. " error in magento2

texts:
while trying to run Cron through Command Prompt getting below error -

Command  -  php bin/magento cron:run

Getting Error -

  [Magento\Framework\Exception\LocalizedException]
                   exec function is disabled.

Can you plz let me know how to enable 'exec' function and run default group name cron properly ?


texts: Magento Multi Store - identical store code/language codes

texts:
I'm refering to this answer: https://magento.stackexchange.com/a/60657/51738

I know this question is quite old but I assume this workaround should still work on Magento 1.9.x and maybe also on Magento 2.x

I'm on Magento 1.9.3.9

I've tried to rework the solution, but now I always get 404 errors when switching the language.

What i try to achive is using identical language codes for several stores in a multi store setup but default shop shouldn't have an language code. In URLs it looks like this:

www.first_store.com
www.first_store.com/en/
www.first_store.com/fr/
www.second_store.com
www.second_store.com/en/
www.second_store.com/fr/
...

What I've done: I've created an website folder in magento root directory and also two sub folders within this website folder. I've copied the index.php and .htaccess to the website folder as well as to the two sub folders. I've modified the index.php as described in the solution. In all folders I've created symlinks for app,lib,.. folder which point to magento root directory.

first_store -> .htaccess,index.php -> Mage::run('first_store_de', 'store');
    en -> .htaccess,index.php -> Mage::run('first_store_en', 'store');
    fr -> .htaccess,index.php -> Mage::run('first_store_fr', 'store');

I've created a virtual host on apache for first_store.com which points on first_store folder.

System > Configuration > Web > Default Config > Add Store Code to Urls is No
System > Configuration > Web I've set Base URL (and the other URLS plus there appendix)

Config Scope: first_store(website) -> http://www.first_store.com/
Config Scope: first_store(de) -> http://www.first_store.com/
Config Scope: first_store(en) -> http://www.first_store.com/en/
Config Scope: first_store(fr) -> http://www.first_store.com/fr/

Testing this in browser shows me that urls act like expected:
Browsing to www.first_store.com shows me the german store view, using the language switch to english opens www.first_store.com/en/ and shows english start page, for french view the same.

The issue occurs when going to an category or product where the url looks like this: www.first_store.com/category/subcategory.html shows me the subcategory in german store view, when I use the language switcher now it calls the url www.first_store.com/en/category/subcategory.html?___store=first_store_en and a 404 occurs. When I manually remove /en from url to get www.first_store.com/category/subcategory.html?___store=first_store_en the site loads the content in english.

My first and bigger problem are these 404 errors which I don't understand. Based on the configuration this shouldn't happen for my understanding. Btw. I'm on a development environment where cache and compilation is disabled, so this can't be the problem.
My second problem is that the language switch still appends the ugly store code when changing the language.


texts:
I did not define any rates in the store before adding products. I have entered all prices in the store gross (with VAT).

1) Now I have set tax rates:

Now magento has added 23% to all prices products in the store.
But I do not want to add an additional 23%.

I want it to display only the tax price on the amount I already have in the store - without adding additional amounts.

anyone help me solve this?


texts: setup:upgrade command when create controller

texts:
I'm creating controller in existing module but when I write url I got 404 not found

should I run php bin/magento setup:upgrade when I add a controller or there is any other command to run?


texts:
I've ben having some trouble with my site since upgrading to Magento ver. 2.4.0.
My products don't appear in the category pages and when I try to reindex I get the following error message:
Catalog Search index process unknown error:
{"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"Types cannot be provided in put mapping requests, unless the include_type_name parameter is set to true."}],"type":"illegal_argument_exception","reason":"Types cannot be provided in put mapping requests, unless the include_type_name parameter is set to true."},"status":400}

From what I've seen through a little research this seems to be related to Elasticsearch so I ran the command: curl -XGET '<hostIP:port>/_cat/health?v&pretty'
And got the message:
epoch      timestamp cluster        status node.total node.data shards pri relo init unassign pending_tasks max_task_wait_time active_shards_percent
1606836115 15:21:55  docker-cluster yellow          1         1      2   2    0    0        2             0                  -                 50.0%

I've seen that this might be due to having the wrong version of Elasticsearch installed but I'm not sure how to upgrade/downgrade my version so any guidance on this would be appreciated.


texts: Simple products not showing in associated tab

texts:
I'm associating my simple products to the configurable products, but in the associated tab the products aren't displayed.

There are products displayed in the tab, but not the products I need
When I search for a specific sku there are still no products found
The Simple products are enabled and in stock
I've used the attributes before in other products
The attributes are set in the simple products


texts: Getting an error while importing products on Magento from my other store

texts: I am having an issue while importing products. Keep getting an error that my csv file is invalid. Can anyone help? I downloaded this file from my other Magento Store. I have also made sure all the categories match. Attached is a screenshot of error.


texts: How to set a hyperlink to my message in magento

texts:
I set a hyperlink to my message to see the price for only logged users.

But when I click on login to see price it is showing my dashboard can u please
help me.


texts: Magento2 Error: "Something went wrong with processing the default view and we have restored the filter to its original state" showing on the loop

texts:
Whenever I open the Catalog Product it gives the following error on loop and continue loading the loader

  Attention Something went wrong.

  Something went wrong with processing the default view and we have
  restored the filter to its original state.

I tried clear the cache(php bin/magento cache:clean)also upgraded magento(php bin/magento setup:upgrade)even given the files and folder permission but still facing the same problem.


texts: Magento 2 - Custom Registration Form For Guest user in custom phtml file

texts: How to build a custom registration form that can be shown in custom phtml file and visible only for guest customer. In the form also show user a checkbox field (mandatory) to confirm account creation and create account after submission.


texts: Where is translation for XML configurations is happening in the code?

texts: In XML files (such as system.xml) I can specify a translate attribute for nodes to be translated. Where is this translation taking place in the code?


texts:
I have an issue in Magento 2.1.6. When I add the same product in cart it's  adding as a new line not update Qty of product.
The same issue in the mini cart also.

Actual Result:
Add as a separate product.

Expected Result:
Update Qty if exist same product.


texts: Programatically Sending Transactional Emails Doesn't Include Products

texts:
When I send out my transactional email programatically, I'm not getting any items in a table like I do when the email is sent automatically.

Looking into the templates, the information is pulled across via:

{{layout handle="sales_email_order_items" order=$order}}

This is sending directive:

$emailTemplate = Mage::getModel('core/email_template')->loadByCode("More Information Required");
$emailTemplate->setSenderEmail(Mage::getStoreConfig('trans_email/ident_general/email', Mage::app()->getStore()->getStoreId()));
$emailTemplate->setSenderName(Mage::getStoreConfig('trans_email/ident_general/name', Mage::app()->getStore()->getStoreId()));
$emailTemplate->send($order->getCustomerEmail(), $order->getCustomerName(), [
    'order' => $order,
    'customer' => $order->getCustomerName(),
    'dateAndTime' => $order->getCreatedAt()
]);

All the data is filled correctly, except the order items grid. Nothing is displayed for this.

Update
To answer the question in the comments, the $order variable is generated as a result of an observer action on an event (in this case, sales_order_save_after). The variable that eventually becomes $order (when passed into a function) is formed as follows:

$observer->getEvent()->getData('data_object')

This contains a standard order object, of the following class: Mage_Sales_Model_Order


texts: Error loading popper.js on Magento 2 Theme (require js)

texts:
I am trying to implement bootstrap v4.0 on magento 2 theme, but I getting popper.js error.

app/design/frontend/vendor/theme/requirejs-config.js

var config = {
    deps: [
        'js/theme'
    ],
    paths: {
        'popper': 'js/bootstrap4/popper.min',
        'bootstrap4': 'js/bootstrap4/bootstrap.min'
    },
    shim: {
        'popper': {
            'deps': ['jquery'],
            'exports': 'Popper'
        },
        'bootstrap4': {
            'deps': ['jquery', 'popper']
        }
    }
};

app/design/frontend/vendor/theme/web/js/theme.js

require(['jquery', 'popper'], function($, Popper) {
    window.Popper = Popper; // re-attach to global scope
    require(['bootstrap4'], function() {
        $(function() {
            // This function is needed (even if empty) to force RequireJS to load Twitter Bootstrap and its Data API.
            // You can make calls to bootstrap functions here.
            alert('ok');
        });
    });
});

Error:

GET http://127.0.0.1/default/popper.js net::ERR_ABORTED require.js:1895
Uncaught Error: Script error for: popper.js require.js:166

Obs:
My bootstrap js files are in app/design/frontend/vendor/theme/web/js/bootstrap4 dir
I am running:
php -f bin/magento setup:upgrade;
sudo chown `whoami`:www-data /var/www/ -R;
cd vendor/snowdog/frontools/;
gulp styles;


texts: How to get lastviewed products programmatically?

texts:
I have a loop in a phtml file that search product for a particular attribute. I am beginner on PHP for Magento and I managed to make this foreach.

What I need now is to make a loop that shows the most recently viewed products programmatically to show in my custom phtml file.

Like this ::: http://image.prntscr.com/image/8111de5ee8a94957bc7bd815f756040c.png

Anyone help me to make this loop?

$_productCollection = Mage::getModel('catalog/product')
    ->getCollection()
    // add sorting to collection optional
    ->addAttributeToFilter('a_nao_pode_faltar_dtumpouco', array('eq' => 1))
    ->addAttributeToSort('created_at', 'DESC')
    ->addAttributeToSelect('*')
    ->load();

    foreach ($_productCollection as $_product){

This loop I made for custom product attribute! Now, I need a loop for lastviewed products.


texts: Magento 2 trying to get the product sizes off from the category page

texts: I'm using magento 2 , and I'm trying to get rid off the product sizes from the catalog page , I only want the size on the product page.. I've tryed to edit Stores -> (Attributes) Product -> dress_size -> Storefront properties -> Visible on Catalog Pages on Storefront set to NO , I save the attribute , clear the cache , but when I come back , Catalog Pages on Storefront is set back to YES.. Does anyone had this issue before ?


texts:
I'm trying to submit an extension for Magento 2.4 but can't pass the "Varnish Test" stage because of the cache that can't be set up on some pages (simple-product and category):

"Expected HIT on the second page load.": ...
"Expected HIT on the second page load after product price update.": ...

I suppose in my case this error is due to the fact that I create cookies from my module code which could prevent the activation of the Varnish cache.
I have created two Observers on "controller_front_send_response_before" and "controller_action_postdispatch" events in which I create cookies with product information. I then retrieve and process this data from the front in JavaScript.
For my local tests, I have activated the varnish cache. When I request a product page or a category I can see the header "X-Magento-Cache-Debug: HIT".
Do you know if there are any special recommendations to follow regarding the creation of cookies in Magento 2 while allowing Varnish caching?
Thank you in advance,


texts: Magento 2.1 UI Component Image upload form

texts:
I am trying to add an image field in my module. I know its been asked before, I tried many provided solutions but can't get it to work. Here's the error I am getting:

While editing old entity:

  /pub/static/adminhtml/Magento/backend/en_US/Magento_Ui/js/form/element/file-uploader.js:69
  Uncaught TypeError: value.map is not a function

While creating new entity, after selecting the uploadable file, I get this on console:

  admin/namespace_module/entity_image/upload/key/dce7aaf794cabba38bc88c52a3317988b859ee4987303d9954ab92c91f9f9049?isAjax=true
  500 (Internal Server Error)

On checking the url above:

  Exception #0 (BadMethodCallException): Missing required argument
  $baseTmpPath of Magento\Catalog\Model\ImageUploader.

My form.xml

<field name="image">
    <argument name="class" xsi:type="string">Namespace\Module\Model\Entity\DataProvider</argument>
    <argument name="data" xsi:type="array">
        <item name="config" xsi:type="array">
            <item name="dataType" xsi:type="string">string</item>
            <item name="source" xsi:type="string">Entity</item>
            <item name="label" xsi:type="string" translate="true">Image</item>
            <item name="visible" xsi:type="boolean">true</item>
            <item name="formElement" xsi:type="string">fileUploader</item>
            <item name="elementTmpl" xsi:type="string">ui/form/element/uploader/uploader</item>
            <item name="previewTmpl" xsi:type="string">Namespace_Module/image-preview</item>
            <item name="required" xsi:type="boolean">false</item>
            <item name="uploaderConfig" xsi:type="array">
                <item name="url" xsi:type="url" path="namespace_module/entity_image/upload"/>
            </item>
        </item>
    </argument>
</field>

My Upload Class:

namespace [Namespace]\[Module]\Controller\Adminhtml\[Entity]\Image;

use Magento\Framework\Controller\ResultFactory;

/**
 * Class Upload
 */
class Upload extends \Magento\Backend\App\Action
{
    /**
     * Image uploader
     *
     * @var \[Namespace]\[Module]\Model\ImageUploader
     */
    protected $imageUploader;

    /**
     * @param \Magento\Backend\App\Action\Context $context
     * @param \Magento\Catalog\Model\ImageUploader $imageUploader
     */
    public function __construct(
        \Magento\Backend\App\Action\Context $context,
        \Magento\Catalog\Model\ImageUploader $imageUploader
    ) {
        parent::__construct($context);
        $this->imageUploader = $imageUploader;
    }

    /**
     * Check admin permissions for this controller
     *
     * @return boolean
     */
    protected function _isAllowed()
    {
        return $this->_authorization->isAllowed('[Namespace]_[Module]::[entity]');
    }

    /**
     * Upload file controller action
     *
     * @return \Magento\Framework\Controller\ResultInterface
     */
    public function execute()
    {
        try {
            $result = $this->imageUploader->saveFileToTmpDir('image');

            $result['cookie'] = [
                'name' => $this->_getSession()->getName(),
                'value' => $this->_getSession()->getSessionId(),
                'lifetime' => $this->_getSession()->getCookieLifetime(),
                'path' => $this->_getSession()->getCookiePath(),
                'domain' => $this->_getSession()->getCookieDomain(),
            ];
        } catch (\Exception $e) {
            $result = ['error' => $e->getMessage(), 'errorcode' => $e->getCode()];
        }
        return $this->resultFactory->create(ResultFactory::TYPE_JSON)->setData($result);
    }
}

Is there something I am missing? Do I need to add/update anyother files?


texts: How to properly override a core JS file in Magento2

texts:
We are attempting to override the behavior of Bundle Products in Magento2, specifically, to enable user defined quantities for Checkbox type products within the bundle.

We have written an extension, and followed instructions about how to replace a default JS component found here: http://devdocs.magento.com/guides/v2.0/javascript-dev-guide/javascript/custom_js.html

Our custom js file is found in (app/code/Endertech/BundleExtended/view/base/web/js) directory

Our requirejs-config.js within our extension's frontend (app/code/Endertech/BundleExtended/view/frontend/) view looks like:

var config = {
    "map": {
        "*": {
            'Magento_Bundle/js/price-bundle': "Endertech_BundleExtended/js/price-bundle"
        }
    }
};

This is having the effect of loading BOTH the core Magento2 price-bundle.js AND our modified version... and the customization we've added to our modified version is not executing... presumably because the Magento2 core version is loading first.

We expected for this revision to PREVENT the core version from loading in favor of ours.

Perhaps we are approaching the problem from the wrong direction, or have some other misunderstanding.

We are seeking a solution to have our modified price-bundle.js be loaded in lieu of the built-in that comes in the Magento Bundle module... or at least a way to override specific methods within and is required here (vendor/magento/module-bundle/view/frontend/requirejs-config.js).

If our approach is wrong, we'd be happy to be corrected!


texts:
In the mytheme/default/template/catalog/product/view.phtml file that I override in my custom theme I have the following code:

$attributeCode = 'myattributecode';
if($value = $this->getProduct()->getData($attributeCode));):
echo $value;

(Sorry, the div elements are not supported by this site.)

On the product page I get the  option_id instead of value.

When I am doing the following, trying to debug:

$attribute = $_product->getResource()->getAttribute('tempspreparation'); var_dump($attribute);die();

I am getting the huge array with:

  ["myattributecode"]=> *RECURSION*

for my attribute code.

Does anyone know what is happening?

Any help will be largely appreciated! Thanks!


texts: Magento 2.1.9 : Cart Rules (Please enter a valid date)

texts:
I have the this started after upgrading from CE2.1.7 to CE2.1.8, Currently my version in CE 2.1.9 but still getting the same issue.

Default Country Spain and locale United Kingdom for now.

=> Screenshot :


texts: Magento2 : How to display custom values in checkout page

texts:
I am working on checkout page, I have pass some array values to checkout config provider.

How to get those values in knockout JS and display by knockout html.

Want to display all applied codes in checkout payment step.

I have passed values to config provider by below code

public function getConfig()
    {
        return $this->getAppliedGiftCards();
    }

    public function getAppliedGiftCards()
    {
        $quoteId = $this->checkoutSession->getQuote()->getId();
        $giftcardCodes = $this->quoteFactory->getGiftCardCollection($quoteId);
        $config = [];
        foreach ($giftcardCodes as $giftcardCode){
            $config['payment']['applied_giftcard'][$giftcardCode->getCode()] = $giftcardCode->getCode();
        }
        return $config;
    }

Get values in Js by below code

var configValues = window.checkoutConfig.payment;
var applied_giftcard = ko.observable(configValues.applied_giftcard);

How to render passed config array value to knockout template.


texts: What is best approach to add a Counter in Custom Module

texts:
I want to count Order placed after My Module installation that counter can be reset By User and have Custom Starting Value and Steps Bases On Config Value
I am thinking of creating New Config Feild
If anyone has a better suggestion please share with me


texts: Add custom category attribute in Magento 2

texts:
I'm tryng to create a custom category attribute using this guide but it doesn't work for me, this is the code that I'm using for the
InstallData.php:

use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Framework\Setup\InstallDataInterface;

use Magento\Eav\Setup\EavSetup;
use Magento\Eav\Setup\EavSetupFactory;

class InstallData implements InstallDataInterface
{
  private $eavSetupFactory;

  public function __construct(EavSetupFactory $eavSetupFactory) {
    $this->eavSetupFactory = $eavSetupFactory;
  }

  public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
  {
    $eavSetup = $this->eavSetupFactory->create(['setup' => $setup]);
    $eavSetup->addAttribute(\Magento\Catalog\Model\Category::ENTITY, 'disposizione', [
        'type'     => 'int',
        'label'    => 'Disposizione',
        'input'    => 'boolean',
        'source'   => 'Magento\Eav\Model\Entity\Attribute\Source\Boolean',
        'visible'  => true,
        'default'  => '0',
        'required' => false,
        'global'   => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE,
        'group'    => 'Display Settings',
    ]);
  }
}

category_form.xml

<?xml version="1.0"?>
<form xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
<fieldset name="display_settings">
    <field name="disposizione">
        <argument name="data" xsi:type="array">
            <item name="config" xsi:type="array">
                <item name="dataType" xsi:type="string">boolean</item>
                <item name="formElement" xsi:type="string">checkbox</item>
                <item name="label" xsi:type="string" translate="true">Nome Produttore</item>
                <item name="prefer" xsi:type="string">toggle</item>
                <item name="valueMap" xsi:type="array">
                    <item name="true" xsi:type="string">1</item>
                    <item name="false" xsi:type="string">0</item>
                </item>
                <item name="default" xsi:type="number">0</item>
            </item>
        </argument>
    </field>
</fieldset>
</form>

module.xml

<?xml version="1.0"?>

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
  <module name="Ng_AddAttribute" setup_version="1.0.0" />
</config>

registration.php

<?php
\Magento\Framework\Component\ComponentRegistrar::register(
  \Magento\Framework\Component\ComponentRegistrar::MODULE,
  'Ng_AddAttribute',
  __DIR__
);

After that i upgrade the schema with bin/magento setup:upgrade and clear the cache, but a error appears when i reload the page:
Exception #0 (Exception): Warning: DOMDocument::loadXML(): XML declaration allowed only at the start of the document in Entity
this is only a try, I need to create two attribute one text and one select.
could someone help me

EDIT:

I've resolved the XML problem and now i can see the field in the backend but it didn't save the data.


texts: Magento 2.1.9 an error has occurred on the server. Please try to place your order again

texts:
I keep on getting this error for credit card processing option. I cannot figure out what's wrong with it. Is anyone else running into this problem?

I'm using Payments Pro from PayPal if that helps. My system is running on Amazon Lightsail Bitnami.


texts: How to get helper method value in knockout js

texts:
I created this method in helper :

public function getMessage()
    {
        return $this->scopeConfig->getValue(self::XML_ERROR_MESSAGE);
    }

I need to display above output in knockout js. I dont know how to get helper method value in knockout js file. Please help me to come out. Thanks.