magento2 – requested product does not exist in the backend model

I need to change the product attribute value after saving, but it gives me a value The requested product does not exist if I save the product

    The class myClass extends Magento  Eav  Model  Entity  Attributes  Backend  AbstractBackend
{
public function afterSave ($ object) {
// your after-saving logic


$ objectManager =  Magento  Framework  App  ObjectManager :: getInstance ();
$ productRepository = $ objectManager-> create (& # 39;  Magento  Catalog  Api  ProductRepositoryInterface & # 39;);
$ product = $ productRepository-> getById ($ productId);
$ product-> setName ($ productName);
$ productRepository-> save ($ product);

return parent :: afterSave ($ object);
}

magento2 – Can we manage the filtering of products by category in Magento 2 Admin Panel

You can do something like that, but without further information, it's hard to determine what you're asking.

Create a product attribute with the standard name as Categories, In that Storefront properties section sentence Use Yes in multilevel navigation,

Then you navigate to Catalog> Categories and choose or create a category. In the categories display settings, to adjust Anchor as yes,

This category should now be visible and filterable. A basic guide can be found here.

magento2 – magernto 2 multiple coupons on offer

I know a lot of post I asked before I asked that question, but they all refer to Magento 1 or do not have a good answer
I would like to put a multi-coupon on course.
I want to like this code

                $ newCouponCode = explode (",", $ couponCode);
foreach ($ newCouponCode as $ cpCode) {

$ quote-> setCouponCode ($ cpCode);
$ this-> quoteRepository-> save ($ quote-> collectTotals ());

For every coupon that the customer has sent to the controller, I explode it and find it sets a price and withholds a rebate. At the end I summarize the discount and use the offer point. My problem is how to remove the coupons or Magento says this coupon will be used. Another problem is how to save the offer and say that Magento no longer gets a discount
Is there a free module for this?

magento2 – How to get a coherent collection of products in the block

Use the following code in your block:

protected $ _productFactory;
Protected $ _registry;

public function __construct (
 Magento  Backend  Block  Template  Context $ Context,
/ Magento  Catalog  Model  ProductFactory $ productFactory,
 Magento  Framework  Registry $ Registry,
Array $ data = []
)
{
$ this -> _ productFactory = $ productFactory;
$ this -> _ registry = $ registry;
parent :: __ construct ($ context, $ data);
}

public function createCollection ()
{
$ product = $ this -> _ productFactory -> create () -> load ($ productId);
// $ product = $ this -> _ registry-> registry (& # 39; current_product & # 39;); // for current product
$ relatedProducts = $ product-> getRelatedProducts ();

return $ relatedProducts;
}

And use the following code in your HTML file:

if (! empty ($ block-> createCollection ())) {
echo & # 39; related products 
& # 39 ;; $ productFactory = $ this -> _ productFactory-> create (); foreach ($ block-> createCollection () as $ relatedProduct) { $ _product = $ productFactory-> load ($ relatedProduct-> getId ()); echo $ relatedProduct-> getId (). & # 39; -> & # 39 ;. $ _ product-> getPrice (). & # 39; -> & # 39 ;. $ _ product-> getName (). & # 39; -> & # 39 ;. $ relatedProduct-> getId (); // get name Echo "
"; } }

magento2 – add / change the product name to the product link

I have a popup on the list page. In the pop-up window I would like to add a product link to the product view.

I have checked and the product name comes from:

Vendor / Magento / Module Theme / view / frontend / templates / html / title.phtml

The code responsible for the sentence class and attribute is


    
        product
        itemprop = "name"
    

The above code is located in:

Manufacturer / Magento / Module Catalog / view / frontend / layout / catalog_product_view.xml

I have tried:

item_prop = "url_key"
    

but the above code does not work.

Thank you in advance!

magento2 – Import "Stop on Error" does not work as expected

The function "Stop on error" in System> Data Transfer> Import does not work as expected. It only seems to work if you search for required columns. For validation errors (for example, "Please make sure the group_id attribute is not empty"), each row (in my case, thousands) will be processed and a list of all broken rows will be output.

I have set the defaults to "Stop on Error", "Allowable Error Count: 10".

Is "Stop on Error" only designed for one type of error (column existence)?

magento2 – Existing products will not be saved after upgrading to Magento 2.3

Recently I upgraded My Magento 2.2.6 to 2.3. After the upgrade I configured Multi Source Inventory. It works as expected when creating new products (and the product created after the upgrade). However, there is an error updating old products (that existed before the upgrade to 2.3).

The following error is issued by the system when saving old products.

The storage location could not be saved. Please try again.

Does anyone have an idea about this problem?

magento2 – Magento 2 Free Quick Cloud Zoom Extension di.xml is not overwritten

This is app / code / ibnab / cloudZoomy / etc / frontend / di.xml

———-
This is phtml app / code / Ibnab / CloudZoomy / view / frontend / templates / product / view / gallery.phtml

getConfigValue (& # 39; ibnab_cloud_config / general / enabledisable & # 39;);
$ jsonGallery = $ block-> getGalleryImagesJson ();
$ arrayJsonGallery = json_decode ($ jsonGallery, true);
$ useragent = $ _ SERVER[‘HTTP_USER_AGENT’];
if ($ typeGallery == 1 &&! preg_match (& # 39; / (android | bb d + | meego). + mobile | avantgo | bada / | blackberry | blazer | compal | elaine | fennec | hiptop | iemobile | ip (hone | od) | iris | child | lge | maemo | midp | mmp | netfront | opera m (ob | in) i | palm (os)? | phone | p (ixi | re) / | plucker | bag | psp | series (4 | 6) 0 | symbian | treo | up . (Browser | link) | vodafone | wap | windows (ce | phone) | xda | xiino / i & # 39 ;, $ useragent) || preg_match (& # 39; / 1207 | 6310 | 6590 | 3gso | 4thp | 50[1-6]i | 770s | 802s | a wa | abac | ac (er | oo | s -) ​​| ai (ko | rn) | al (av | ca | co) | amoi | at (ex | ny | yw) | aptu | ar (ch | go) | as (te | us) | attw | au (di | -m | r | s) | avan | be (ck | ll | nq) | bi (lb | rd) | bl (ac | az) | br (e | v) w | bumb | bw – (n | u) | c55 / | capi | ccwa | cdm | – | cell | chtm | cldc | cmd – | co (mp | nd) | craw | there (it | ll | ng) | dbte | dc -s | devi | dica | dmob | do (c | p) o | ds (12 | -d) | el (49 | ai) | em (l2 | ul) | he (ic | k0) | esl8 | ez ([4-7]0 os | wa | ze) | fetc | fly ( – | _) | g1 u | g560 | gene | gf -5 | g -mo | go (. W | od) | gr (ad | un | hie | hcit | hd – (m | p | t) | hei – | hi (pt | ta) | hp (i | ip) | hs -c | ht (c ( – | | _ | (20 | go | ma) | i230 | iac (| – | /) | ibro | idea | ig01 | ikom | im1k | inno | ipaq | iris | yes (t | v) a | jbro | jemu | jigs | kddi | keji | kgt (| /) | clone | kpt | kwc – | kyo (c | k) | le (no | xi) | lg (g | / (k | l | u) | 50 | 54 | -[a-w]| libw | lynx | m1 -w | m3ga | m50 | / | ma (te | ui | xo) | mc (01 | 21 | ca) | m -cr | me (rc | ri) | mi (o8 | oa | ts | mmef | mo (01 | 02 | bi | DE | do | t ( – | | o | v) | zz) | mt (50 | p1 | v) | mwbp | mywa | n10[0-2]| n20[2-3]| n30 (0 | 2) | n50 (0 | 2 | 5) | n7 (0 (0 | 1) | 10) | ne ((c | m) | – | on | tf | wf | wg | wt) | nok (6 | i) | nzph | o2im | op (ti | wv) | oran | owg1 | p800 | pan (a | d | t) | pdxg | pg (13 | – ([1-8]| c)) | phil | pire | pl (ay | uc) | pn -2 | po (ck | rt | se) | prox | psio | pt -g | qa -a | qc (07 | 12 | 21 | 32 | 60 | -[2-7]| i -) ​​| qtek | r380 | r600 | raks | rim9 | ro (ve | zo) | s55 / | sa (ge | ma | mm | ms | ny | va) | sc (01 | h – | oo | p -) ​​| sdk / | se (c ( – | 0 | 1) | 47 | mc | nd | ri) | sgh – | shar | they ( – | m) | sk -0 | sl (45 | id) | sm (al | ar | b3 | it | t5) | so (ft | ny) | sp (01 | h – | v – | v) | sy (01 | mb) | t2 (18 | 50) | t6 (00 | 10 | 18) | ta (gt | lk) | tcl – | tdg – | tel (i | m) | tim – | t-mo | until (pl | sh) | ts (70 | m – | m3 | m5) | tx -9 | up (. b | g1 | si) | utst | v400 | v750 | veri | vi (rg | te) | vk (40 | 5[0-3]| -v) | vm40 | voda | vulc | vx (52 | 53 | 60 | 61 | 70 | 80 | 83 | 85 | 98) | w3c ( – |) | webc | whit | wi (g | nc | nw) | wmlb | wonu | x700 | yas – | Your | zeto | zte – / i & # 39 ;, substr ($ useragent, 0,4))):
?>

"class = & # 39; cloud-zoom & # 39; id = & # 39; zoom1 & # 39; rel =" ">
"title =" "/>

  • & # 39; class = & # 39; Cloud-zoom-gallery & # 39; title = & # 39; Thumbnail & # 39;
    rel = "useZoom: & # 39; zoom1 & # 39 ;, smallImage: & # 39;">
    "alt =" "/>

    

getViewFileUrl (& # 39; images / loader-1.gif & # 39;); ?> "
old = "">

var config = {
"width": getImageAttribute (& # 39; product_page_image_medium & # 39 ;, & # 39; width & # 39;); ?>
"thumbheight": getImageAttribute (& # 39; product_page_image_small & # 39 ;, & # 39; height & # 39;)
?: $ block-> getImageAttribute (& # 39; product_page_image_small & # 39 ;, & # 39; width & # 39;); ?>
"navtype": "getVar (" gallery / navtype ");?>",
"height": getImageAttribute (& # 39; product_page_image_medium & # 39 ;, & # 39; height & # 39;); ?>
},
thumbBarHeight = 0,
loader = document.querySelectorAll (& # 39;[data-gallery-role=”gallery-placeholder”] [data-role=”loader”]& # 39)[0];

if (config.navtype === & # 39; horizontal & # 39;) {
thumbBarHeight = config.thumbheight;
}

loader.style.paddingBottom = (config.height / config.width * 100) + "%";

{
"[data-gallery-role=gallery-placeholder]": {
"Magician / Gallery / Gallery": {
"Mixins":[“magnifier/magnify”],
"magnifierOpts": getMagnifier (); ?>
"data": getGalleryImagesJson (); ?>
"Options": {
"nav": "getVar (" gallery / nav ");?>",
getVar ("gallery / loop"))):?>
"Loop": getVar ("gallery / loop"); ?>

getVar ("Gallery / Keyboard"))):?>
"keyboard": getVar ("gallery / keyboard"); ?>

getVar ("Gallery / Arrows"))):?>
"arrows": getVar ("gallery / arrows"); ?>

getVar ("gallery / allowfullscreen"))):?>
"allowfullscreen": getVar ("gallery / allowfullscreen"); ?>

getVar ("gallery / caption"))):?>
"showCaption": getVar ("Gallery / Subtitles"); ?>

"width": "getImageAttribute (& # 39; product_page_image_medium & # 39 ;, width & # 39;);?>",
"thumbwidth": "getImageAttribute (& # 39; product_page_image_small & # 39 ;, width & # 39;);?>",
getImageAttribute (& # 39; product_page_image_small & # 39 ;, height & # 39;) || $ block-> getImageAttribute (& # 39; product_page_image_small & # 39 ;, & # 39; width & # 39;)):?>
"thumbheight": getImageAttribute (& # 39; product_page_image_small & # 39 ;, & # 39; height & # 39;)
?: $ block-> getImageAttribute (& # 39; product_page_image_small & # 39 ;, & # 39; width & # 39;); ?>

getImageAttribute (& # 39; product_page_image_medium & # 39 ;, height & # 39;) || $ block-> getImageAttribute (& # 39; product_page_image_medium & # 39 ;, & # 39; width & # 39;)):?>
"height": getImageAttribute (& # 39; product_page_image_medium & # 39 ;, & # 39; height & # 39;)
?: $ block-> getImageAttribute (& # 39; product_page_image_medium & # 39 ;, & # 39; width & # 39;); ?>

getVar ("Gallery / Transition / Duration")):?>
"Transition Duration": getVar ("Gallery / Transition / Duration"); ?>

"Transition": "getVar (" Gallery / Transition / Effect ");?>",
getVar ("gallery / navarrows"))):?>
"navarrows": getVar ("gallery / navarrows"); ?>

"navtype": "getVar (" gallery / navtype ");?>",
"navdir": "getVar (" gallery / navdir ");?>"
},
"Full screen": {
"nav": "getVar (" gallery / fullscreen / nav ");?>",
getVar ("Gallery / Full Screen / Loop"):?>
"Loop": getVar ("gallery / frame / loop"); ?>

"navdir": "getVar (" gallery / fullscreen / navdir ");?>",
getVar ("Gallery / Transition / Navarrows")):?>
"navarrows": getVar ("gallery / fullscreen / navarrows"); ?>

"navtype": "getVar (" gallery / fullscreen / navtype ");?>",
getVar ("Gallery / Fullscreen / Arrows")):?>
"Arrows": getVar ("Gallery / Fullscreen / Arrows"); ?>

getVar ("gallery / fullscreen / caption"):?>
"showCaption": getVar ("Gallery / Full Screen / Subtitles"); ?>

getVar ("Gallery / Fullscreen / Transition / Duration"):?>
"Transition Duration": getVar ("Gallery / Fullscreen / Transition / Duration"); ?>

"Transition": "getVar (" Gallery / Fullscreen / Transition / Effect ");?>"
},
"Breakpoints": getBreakpoints (); ?>
}
}
}


This is the PHP class app code Ibnab CloudZoomy Block Product View

Namespace Ibnab CloudZoomy Block Product View;

use Magento Framework Data Collection;
use Magento Framework Json EncoderInterface;
Use Magento Catalog Helper Image;
Use Magento Framework App Config ScopeConfigInterface.

The Gallery class extends Magento Catalog Block Product View AbstractView
{
/ **
* @var Magento Framework Config View
* /
protected $ configView;

/ **
* @var  Magento  Framework  Json  EncoderInterface
* /
Protected $ jsonEncoder;


protected $ _template = & # 39; Ibnab_CloudZoomy :: product / view / gallery.phtml & # 39 ;;

/ **
* @var Ibnab  CloudZoomy  Helper  Data
* /
protected $ dataHelper;
/ **
* @param  Magento  Catalog  Block  Product  Context $ Context
* @param  Magento  Framework  Stdlib  ArrayUtils $ arrayUtils
* @param EncoderInterface $ jsonEncoder
* @param array $ data
* /
public function __construct (
 Ibnab  CloudZoomy  Helper  Data $ dataHelper,
 Magento  Catalog  Block  Product  Context $ Context,
 Magento  Framework  Stdlib  ArrayUtils $ arrayUtils,
EncoderInterface $ jsonEncoder,
Array $ data = []
) {
$ this-> jsonEncoder = $ jsonEncoder;
$ this-> dataHelper = $ dataHelper;
parent :: __ construct ($ context, $ arrayUtils, $ data);
}

/ **
* Retrieve collection of gallery images
*
* @return collection
* /
public function getGalleryImages ()
{
$ product = $ this-> getProduct ();
$ images = $ product-> getMediaGalleryImages ();
if ($ images instance of  Magento  Framework  Data  Collection) {
foreach ($ images as $ image) {
/ * @var  Magento  Framework  DataObject $ image * /
$ image-> setData (
& # 39; # 39 ;, & small_image_url
$ this -> _ imageHelper-> init ($ product, & # 39; product_page_image_small & # 39;)
-> setImageFile ($ image-> getFile ())
-> getUrl ()
);
$ image-> setData (
"Medium_image_url"
$ this -> _ imageHelper-> init ($ product, & # 39; product_page_image_medium & # 39;)
-> constrainOnly (true) -> keepAspectRatio (true) -> keepFrame (false)
-> setImageFile ($ image-> getFile ())
-> getUrl ()
);
$ image-> setData (
& # 39; # 39 ;, & large_image_url
$ this -> _ imageHelper-> init ($ product, & # 39; product_page_image_large & # 39;)
-> constrainOnly (true) -> keepAspectRatio (true) -> keepFrame (false)
-> setImageFile ($ image-> getFile ())
-> getUrl ()
);
}
}

Return $ images;
}

/ **
* Return magnifying glass options
*
* @return string
* /
public function getMagnifier ()
{
return $ this-> jsonEncoder-> encode ($ this-> getVar (& # 39; magnifier & # 39;));
}

/ **
* Return breakpoint options
*
* @return string
* /
public function getBreakpoints ()
{
return $ this-> jsonEncoder-> encode ($ this-> getVar (& # 39; breakpoints & # 39;));
}

/ **
* Retrieve product images in JSON format
*
* @return string
* /
public function getGalleryImagesJson ()
{
$ imagesItems = [];
foreach ($ this-> getGalleryImages () as $ image) {
$ imagesItems[] = [
            'thumb' => $image->getData('small_image_url'),
            'img' => $image->getData('medium_image_url'),
            'full' => $image->getData('large_image_url'),
            'caption' => $image->getLabel(),
            'position' => $image->getPosition(),
            'isMain' => $this->isMainImage($image),
        ];
}
if (empty ($ imagesItems)) {
$ imagesItems[] = [
            'thumb' => $this->_imageHelper->getDefaultPlaceholderUrl('thumbnail'),
            'img' => $this->_imageHelper->getDefaultPlaceholderUrl('image'),
            'full' => $this->_imageHelper->getDefaultPlaceholderUrl('image'),
            'caption' => '',
            'position' => '0',
            'isMain' => true,
        ];
}
return json_encode ($ imagesItems);
}

/ **
* Get Gallery URL
*
* @param null |  Magento  Framework  DataObject $ image
* @return string
* /
public function getGalleryUrl ($ image = null)
{
$ params = ['id' => $this->getProduct()->getId()];
if ($ image) {
$ params['image'] = $ image-> getValueId ();
}
return $ this-> getUrl (& # 39; catalog / product / gallery & # 39 ;, $ params);
}

/ **
* Is the main picture of the product
*
* @param  Magento  Framework  DataObject $ image
* @ return bool
* /
public function isMainImage ($ image)
{
$ product = $ this-> getProduct ();
return $ product-> getImage () == $ image-> getFile ();
}

/ **
* @param string $ imageId
* @ param string $ attributname
* @param string $ default
* @return string
* /
public function getImageAttribute ($ imageId, $ attributeName, $ default = null)
{
$ attributes =
$ this-> getConfigView () -> getMediaAttributes (& # 39; Magento_Catalog & # 39 ;, Image :: MEDIA_TYPE_CONFIG_NODE, $ imageId);
Return value ($ attributes)[$attributeName]) $ Attributes[$attributeName] : $ default;
}

/ **
* Retrieve configuration view
*
* @return  Magento  Framework  Config  View
* /
private function getConfigView ()
{
if (! $ this-> configView) {
$ this-> configView = $ this -> _ viewConfig-> getViewConfig ();
}
return $ this-> configView;
}

public function getConfigValue ($ path) {
return $ this-> dataHelper-> getValue ($ path, ScopeConfigInterface :: SCOPE_TYPE_DEFAULT);
}

}

magento2 – How can I recover Magento Cloud environments that have been deleted by the GitHub integration?

I followed the instructions to set up a GitHub integration with my Magento Cloud Pro project. This project has not been live yet, but has been in development for several months and has therefore committed 1k +. I took a snapshot of my integration environment and ran the command as documented:

magento-cloud integration: add --type = github --project ...

There were additional calls that appeared after running, with seemingly reasonable default values ​​that I accepted.

Creating pull requests (--build-pull requests)
Create any pull request as environment? [Y|n] 

Create pull requests after merge (--build-pull-request-post-merge)
Create pull requests based on their post-merge status? [y|N] 

Clone data for pull requests (--pull-request-clone-parent-data)
Do you clone the parent environment data for pull requests? [Y|n] 

Get branches (--fetch branches)
Get all branches from the remote (as inactive environments)? [Y|n] 

Plum branches (prune branches)
Delete branches that are not present on the remote control. [Y|n] 

After the last question a webhook was created and the integration was created.

Oh, then it cleared all my environments except master, production, and production,

Bye, bye, bye

I suppose it's the last call that messed me up --prune branches, Too bad I'm not pausing to think about what that could do (Note: This option is not documented in the instructions.

What can I do to restore these environments?

Unlike deleting an environment through the Magento Cloud interface, these seem to be path, They are not there and disabled.

Configuration – Is there any reason why Magento2 decided against a default configuration file format?

Is there any reason why Magento2 decided against a default configuration file format? Has the rest of the world so misunderstood?

I love the fact that they decided to use a lot of XML in their framework, but decided not to use it for the actual environment configuration. I ask if we should all just use simple code so we can keep the annoying automation out, or … wait, that's incredibly stupid.

What is the reason for Magento 2 Core developers for this extra genius example?